Skip to content

Commit 463ef5f

Browse files
author
linshun
committed
2 parents 2dcc367 + cea7e1c commit 463ef5f

File tree

11 files changed

+52
-34
lines changed

11 files changed

+52
-34
lines changed

cocos2d/Draw_Nodes/CCDrawNode.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ cc.DrawNode = cc.Node.extend({
142142

143143
if (element.type === cc.DRAWNODE_TYPE_SEGMENT) {
144144
context.strokeStyle = "rgba(" + (0|(element.color.r * 255)) + "," + (0|(element.color.g * 255)) + "," + (0|(element.color.b * 255)) + "," + element.color.a + ")";
145-
context.lineWidth = element.radius;
145+
context.lineWidth = element.radius * 2;
146146
context.lineCap = "round";
147147
cc.drawingUtil.drawLine(element.from, element.to);
148148
}
@@ -151,11 +151,11 @@ cc.DrawNode = cc.Node.extend({
151151
context.fillStyle = "rgba(" + (0|(element.fillColor.r * 255)) + "," + (0|(element.fillColor.g * 255)) + ","
152152
+ (0|(element.fillColor.b * 255)) + "," + element.fillColor.a + ")";
153153
cc.drawingUtil.drawPoly(element.verts, element.count, false, true);
154-
context.lineWidth = element.borderWidth;
154+
context.lineWidth = element.borderWidth * 2;
155155
context.lineCap = "round";
156156
context.strokeStyle = "rgba(" + (0|(element.borderColor.r * 255)) + "," + (0|(element.borderColor.g * 255)) + ","
157157
+ (0|(element.borderColor.b * 255)) + "," + element.borderColor.a + ")";
158-
cc.drawingUtil.drawPoly(element.verts, element.count, false, false);
158+
cc.drawingUtil.drawPoly(element.verts, element.count, true, false);
159159
}
160160
}
161161

cocos2d/actions/CCActionEase.js

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ cc.EaseExponentialOut = cc.ActionEase.extend(/** @lends cc.EaseExponentialOut# *
315315
* @param {Number} time1
316316
*/
317317
update:function (time1) {
318-
this._other.update(time1 == 1 ? 1 : (-(Math.pow(2, -10 * time1 )) + 1));
318+
this._other.update(time1 == 1 ? 1 : (-(Math.pow(2, -10 * time1)) + 1));
319319
},
320320

321321
/**
@@ -674,32 +674,28 @@ cc.EaseElasticInOut = cc.EaseElastic.extend(/** @lends cc.EaseElasticInOut# */{
674674
*/
675675
update:function (time1) {
676676
var newT = 0;
677-
if (time1 == 0 || time1 == 1) {
677+
if (time1 === 0 || time1 === 1) {
678678
newT = time1;
679679
} else {
680680
time1 = time1 * 2;
681-
if (!this._period) {
681+
if (!this._period)
682682
this._period = 0.3 * 1.5;
683-
}
684683

685684
var s = this._period / 4;
686-
687685
time1 = time1 - 1;
688-
if (time1 < 0) {
686+
if (time1 < 0)
689687
newT = -0.5 * Math.pow(2, 10 * time1) * Math.sin((time1 - s) * Math.PI * 2 / this._period);
690-
} else {
688+
else
691689
newT = Math.pow(2, -10 * time1) * Math.sin((time1 - s) * Math.PI * 2 / this._period) * 0.5 + 1;
692-
}
693690
}
694-
695691
this._other.update(newT);
696692
},
697693

698694
/**
699695
* @return {cc.ActionInterval}
700696
*/
701697
reverse:function () {
702-
return cc.EaseInOut.create(this._other.reverse(), this._period);
698+
return cc.EaseElasticInOut.create(this._other.reverse(), this._period);
703699
}
704700
});
705701

cocos2d/actions/CCActionInstant.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -284,9 +284,9 @@ cc.CallFunc = cc.ActionInstant.extend(/** @lends cc.CallFunc# */{
284284
* @return {Boolean}
285285
*/
286286
initWithTarget:function (selector, selectorTarget, data) {
287-
this._data = data || null;
288-
this._callFunc = selector || null;
289-
this._selectorTarget = selectorTarget || null;
287+
this._data = data;
288+
this._callFunc = selector;
289+
this._selectorTarget = selectorTarget;
290290
return true;
291291
},
292292

cocos2d/actions/CCActionInterval.js

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,7 @@ cc.MoveTo = cc.ActionInterval.extend(/** @lends cc.MoveTo# */{
780780
*/
781781
startWithTarget:function (target) {
782782
cc.ActionInterval.prototype.startWithTarget.call(this, target);
783-
this._startPosition = target.getPosition();
783+
this._previousPosition = this._startPosition = target.getPosition();
784784
this._delta = cc.pSub(this._endPosition, this._startPosition);
785785
},
786786

@@ -789,8 +789,13 @@ cc.MoveTo = cc.ActionInterval.extend(/** @lends cc.MoveTo# */{
789789
*/
790790
update:function (time) {
791791
if (this._target) {
792-
this._target.setPosition(cc.p(this._startPosition.x + this._delta.x * time,
793-
this._startPosition.y + this._delta.y * time));
792+
var currentPos = this._target.getPosition();
793+
var diff = cc.pSub(currentPos, this._previousPosition);
794+
this._startPosition = cc.pAdd(this._startPosition, diff);
795+
var newPos = cc.p(this._startPosition.x + this._delta.x * time,
796+
this._startPosition.y + this._delta.y * time);
797+
this._target.setPosition(newPos);
798+
this._previousPosition = newPos;
794799
}
795800
},
796801

@@ -1068,7 +1073,7 @@ cc.JumpBy = cc.ActionInterval.extend(/** @lends cc.JumpBy# */{
10681073
*/
10691074
startWithTarget:function (target) {
10701075
cc.ActionInterval.prototype.startWithTarget.call(this, target);
1071-
this._startPosition = target.getPosition();
1076+
this._previousPosition = this._startPosition = target.getPosition();
10721077
},
10731078

10741079
/**
@@ -1079,8 +1084,16 @@ cc.JumpBy = cc.ActionInterval.extend(/** @lends cc.JumpBy# */{
10791084
var frac = time * this._jumps % 1.0;
10801085
var y = this._height * 4 * frac * (1 - frac);
10811086
y += this._delta.y * time;
1087+
10821088
var x = this._delta.x * time;
1083-
this._target.setPosition(cc.p(this._startPosition.x + x, this._startPosition.y + y));
1089+
1090+
var currentPos = this._target.getPosition();
1091+
1092+
var diff = cc.pSub(currentPos, this._previousPosition);
1093+
this._startPosition = cc.pAdd(diff, this._startPosition);
1094+
var newPos = cc.pAdd(this._startPosition, cc.p(x, y));
1095+
this._target.setPosition(newPos);
1096+
this._previousPosition = newPos;
10841097
}
10851098
},
10861099

cocos2d/actions/CCActionManager.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ cc.ActionManager = cc.Class.extend({
9898
}
9999
//creates a array for that eleemnt to hold the actions
100100
this._actionAllocWithHashElement(element);
101-
cc.Assert((element.actions.indexOf(action) == -1), "ActionManager.addAction(),");
102101

103102
element.actions.push(action);
104103
action.startWithTarget(target);

cocos2d/base_nodes/CCNode.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,7 +1026,9 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{
10261026
*/
10271027
removeFromParent:function (cleanup) {
10281028
if (this._parent) {
1029-
cleanup = cleanup || true;
1029+
if (cleanup == null){
1030+
cleanup = true;
1031+
}
10301032
this._parent.removeChild(this, cleanup);
10311033
}
10321034
},
@@ -1051,7 +1053,9 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{
10511053
return;
10521054
}
10531055

1054-
cleanup = cleanup || true;
1056+
if (cleanup == null){
1057+
cleanup = true;
1058+
}
10551059
if (this._children.indexOf(child) > -1) {
10561060
this._detachChild(child, cleanup);
10571061
}
@@ -1090,7 +1094,9 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{
10901094
removeAllChildren:function (cleanup) {
10911095
// not using detachChild improves speed here
10921096
if (this._children != null) {
1093-
cleanup = cleanup || true;
1097+
if (cleanup == null){
1098+
cleanup = true;
1099+
}
10941100
for (var i = 0; i < this._children.length; i++) {
10951101
var node = this._children[i];
10961102
if (node) {

cocos2d/label_nodes/CCLabelBMFont.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{
537537
* @param {String} fntFile
538538
* @param {String} width
539539
* @param {Number} alignment
540-
* @param {Number} imageOffset
540+
* @param {cc.Point} imageOffset
541541
* @return {Boolean}
542542
*/
543543
initWithString:function (str, fntFile, width, alignment, imageOffset) {
@@ -564,7 +564,7 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{
564564
if (this.initWithTexture(texture, theString.length)) {
565565
this._alignment = alignment || cc.TEXT_ALIGNMENT_LEFT;
566566
this._imageOffset = imageOffset || cc.PointZero();
567-
this._width = width || cc.LabelAutomaticWidth;
567+
this._width = (width == null)?cc.LabelAutomaticWidth:width;
568568
this._opacity = 255;
569569
this._color = cc.white();
570570
this._contentSize = cc.SizeZero();
@@ -1035,7 +1035,7 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{
10351035
* @param {String} fntFile
10361036
* @param {String} width
10371037
* @param {Number} alignment
1038-
* @param {Number} imageOffset
1038+
* @param {cc.Point} imageOffset
10391039
* @return {cc.LabelBMFont|Null}
10401040
* @example
10411041
* // Example 01

cocos2d/layers_scenes_transitions_nodes/CCLayer.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,9 @@ cc.LayerColor = cc.Layer.extend(/** @lends cc.LayerColor# */{
635635
},
636636

637637
/**
638-
* @param color
638+
* @param {cc.Color4B} color
639+
* @param {Number} width
640+
* @param {Number} height
639641
* @return {Boolean}
640642
*/
641643
init:function (color, width, height) {

cocos2d/misc_nodes/CCRenderTexture.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,8 @@ cc.RenderTexture = cc.Node.extend(/** @lends cc.RenderTexture# */{
152152
*/
153153
initWithWidthAndHeight:function (width, height, format, depthStencilFormat) {
154154
if (cc.renderContextType == cc.CANVAS) {
155-
this.canvas.width = width || 10;
156-
this.canvas.height = height || 10;
155+
this.canvas.width = (width == null) ? 10 : width;
156+
this.canvas.height = (height == null) ? 10 : height;
157157

158158
this.context.translate(0, this.canvas.height);
159159

cocos2d/sprite_nodes/CCAnimationCache.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ cc.AnimationCache = cc.Class.extend(/** @lends cc.AnimationCache# */{
6969
* @return {cc.Animation}
7070
*/
7171
getAnimation:function (name) {
72-
if(this._animations.hasOwnProperty(name))
72+
if (this._animations.hasOwnProperty(name))
7373
return this._animations[name];
7474
return null;
7575
},
@@ -173,7 +173,9 @@ cc.AnimationCache = cc.Class.extend(/** @lends cc.AnimationCache# */{
173173

174174
for (var key in animations) {
175175
var animationDict = animations[key];
176-
var loops = parseInt(animationDict["loops"]) || 1;
176+
177+
var loopsTemp = parseInt(animationDict["loops"]);
178+
var loops = (loopsTemp == null) ? 1 : loopsTemp;
177179
var restoreOriginalFrame = (animationDict["restoreOriginalFrame"] && animationDict["restoreOriginalFrame"] == true) ? true : false;
178180
var frameArray = animationDict["frames"];
179181

cocos2d/support/CCUserDefault.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ cc.UserDefault = cc.Class.extend(/** @lends cc.UserDefault# */{
113113
*/
114114
getFloatForKey:function (key, defaultValue) {
115115
var value = this._getValueForKey(key);
116-
var ret = defaultValue || 0.0;
116+
var ret = defaultValue || 0;
117117

118118
if (value) {
119119
return parseFloat(value);

0 commit comments

Comments
 (0)