Skip to content

Commit

Permalink
[JSB] Some fixes for cc.DrawNode: (#19889)
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
ricardopetrere authored and minggo committed Jul 2, 2019
1 parent 9afcfa2 commit 95d0273
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions cocos/scripting/js-bindings/script/jsb_cocos2d.js
Original file line number Diff line number Diff line change
Expand Up @@ -1779,7 +1779,7 @@ cc._DrawNode.prototype.drawPoly = function (verts, fillColor, borderWidth, borde
cc._DrawNode.prototype.drawPolygon.call(this, verts, verts.length, fillColor, borderWidth, borderColor);
}
cc.DrawNode = cc._DrawNode.extend({
_drawColor: cc.color(255, 255, 255, 255),
_drawColor: null,
_lineWidth: 1,

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

drawSegment:function (from, to, lineWidth = this._lineWidth, color = this._drawColor) {
drawSegment:function (from, to, lineWidth, color) {
lineWidth = lineWidth || this._lineWidth;
color = color || this._drawColor;
cc._DrawNode.prototype.drawSegment.call(this, from, to, lineWidth, color);
},

Expand Down
1 change: 1 addition & 0 deletions cocos/scripting/js-bindings/script/jsb_create_apis.js
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,7 @@ cc.ClippingNode.prototype._ctor = function(stencil) {

cc.DrawNode.prototype._ctor = function() {
cc.DrawNode.prototype.init.call(this);
this._drawColor = cc.color(255, 255, 255, 255);
};

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

0 comments on commit 95d0273

Please sign in to comment.