Skip to content

Commit 2d5f56b

Browse files
DrawNode fix 2:
Ignore previous patch. DrawNode is compatible with JSB.
1 parent 81a29bd commit 2d5f56b

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

cocos2d/Draw_Nodes/CCDrawNode.js

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -275,10 +275,10 @@ cc.DrawNode = cc.Node.extend({
275275
},
276276

277277
/** draw a polygon with a fill color and line color */
278-
drawPolyWithVerts:function (verts, count, fillColor, width, borderColor) {
278+
drawPoly:function (verts, fillColor, width, borderColor) {
279279
var element = new cc._DrawNodeElement(cc.DRAWNODE_TYPE_POLY);
280-
element.verts = cc.DrawNode.convertVerts(verts);
281-
element.count = count;
280+
element.verts = verts;
281+
element.count = verts.length;
282282
element.fillColor = fillColor;
283283
element.borderWidth = width;
284284
element.borderColor = borderColor;
@@ -395,10 +395,3 @@ cc._DrawNodeElement = function (type) {
395395
cc.DRAWNODE_TYPE_DOT = 0;
396396
cc.DRAWNODE_TYPE_SEGMENT = 1;
397397
cc.DRAWNODE_TYPE_POLY = 2;
398-
cc.DrawNode.convertVerts = function (verts) {
399-
var ret = [];
400-
for (var i = 0; i < verts.length / 2; i++) {
401-
ret[i] = {x:verts[i * 2], y:verts[i * 2 + 1]};
402-
}
403-
return ret;
404-
};

cocos2d/physics_nodes/CCPhysicsDebugNode.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@
3434
as the private API may change with little or no warning.
3535
*/
3636

37+
// Helper. Converts an array of numbers into an array of vectors(x,y)
38+
cc.__convertVerts = function (verts) {
39+
var ret = [];
40+
for (var i = 0; i < verts.length / 2; i++) {
41+
ret[i] = {x:verts[i * 2], y:verts[i * 2 + 1]};
42+
}
43+
return ret;
44+
};
45+
3746
cc.ColorForBody = function (body) {
3847
if (body.isRogue() || body.isSleeping()) {
3948
return cc.c4f(0.5, 0.5, 0.5, 0.5);
@@ -57,7 +66,7 @@ cc.DrawShape = function (shape, renderer) {
5766
break;
5867
case cp.PolyShape.prototype.collisionCode:
5968
var line = cc.c4f(color.r, color.g, color.b, cc.lerp(color.a, 1.0, 0.5));
60-
this.drawPolyWithVerts(shape.tVerts, shape.getNumVerts(), color, 1.0, line);
69+
this.drawPoly(cc.__convertVerts(shape.tVerts), color, 1.0, line);
6170
break;
6271
default:
6372
cc.Assert(false, "Bad assertion in DrawShape()");
@@ -153,4 +162,5 @@ cc.PhysicsDebugNode.debugNodeForCPSpace = function (space) {
153162
return null;
154163
};
155164

156-
cc.PhysicsDebugNode.create = cc.PhysicsDebugNode.debugNodeForCPSpace;
165+
cc.PhysicsDebugNode.create = cc.PhysicsDebugNode.debugNodeForCPSpace;
166+

0 commit comments

Comments
 (0)