Doing is trying to draw a rectangle with the basic drawing function, you can use the Drawnode in Cocos2d-js 3.0.
var New cc. Drawnode (); var ltp = CC.P (0, +); var rbp = CC.P (0); Dn.drawrect (LTP, RBP, Cc.color (255, 0, 0));
Add the Drawnode to the layer.
this. AddChild (DN)
The drawing operation on the DN is recorded into an internal buffer containing information about each operation, and then the operation is replayed once it is visit. This is determined by the node in which it is located, and if there are other sprites on it will be obscured.
Drawnode contains many drawing functions, including the canvas version and the WEBGL version, as in many other classes. In fact, ccdrawingprimitivescanvas.js and Ccdrawingprimitiveswebgl contain more and finer functions, but do not know how to call directly.
COCOS2D-JS Development Record: Basic graphic drawing