Skip to content

Commit 95d0273

Browse files
ricardopetrereminggo
authored andcommitted
[JSB] Some fixes for cc.DrawNode: (#19889)
- It was using the same _drawColor field for all instances - drawSegment() was not checking the optional parameters the way web does, which led to different outcomes
1 parent 9afcfa2 commit 95d0273

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

cocos/scripting/js-bindings/script/jsb_cocos2d.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1779,7 +1779,7 @@ cc._DrawNode.prototype.drawPoly = function (verts, fillColor, borderWidth, borde
17791779
cc._DrawNode.prototype.drawPolygon.call(this, verts, verts.length, fillColor, borderWidth, borderColor);
17801780
}
17811781
cc.DrawNode = cc._DrawNode.extend({
1782-
_drawColor: cc.color(255, 255, 255, 255),
1782+
_drawColor: null,
17831783
_lineWidth: 1,
17841784

17851785
release: function () {},
@@ -1895,7 +1895,9 @@ cc.DrawNode = cc._DrawNode.extend({
18951895
cc._DrawNode.prototype.drawDot.call(this, pos, radius, color);
18961896
},
18971897

1898-
drawSegment:function (from, to, lineWidth = this._lineWidth, color = this._drawColor) {
1898+
drawSegment:function (from, to, lineWidth, color) {
1899+
lineWidth = lineWidth || this._lineWidth;
1900+
color = color || this._drawColor;
18991901
cc._DrawNode.prototype.drawSegment.call(this, from, to, lineWidth, color);
19001902
},
19011903

cocos/scripting/js-bindings/script/jsb_create_apis.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -774,6 +774,7 @@ cc.ClippingNode.prototype._ctor = function(stencil) {
774774

775775
cc.DrawNode.prototype._ctor = function() {
776776
cc.DrawNode.prototype.init.call(this);
777+
this._drawColor = cc.color(255, 255, 255, 255);
777778
};
778779

779780
cc.LabelAtlas.prototype._ctor = function(strText, charMapFile, itemWidth, itemHeight, startCharMap) {

0 commit comments

Comments
 (0)