1、向量相减 cc.pSub(vec1, vec2) ---> vec1.sub(vec2)
2、cc.DrawNode、this.draw_node.drawSegment ---> cc.Graphics
API https://blog.csdn.net/qq_37849776/article/details/79528552
// 画线段 //1.x代码 this.draw_node = new cc.DrawNode(); this.node._sgNode.addChild(this.draw_node); this.draw_node.drawSegment(cc.v2(xpos, ypos), cc.v2(xpos + 1, ypos + 1), 1, cc.color(0, 255, 0, 255)); // 2.x 废弃了cc.DrawNode 采用cc.Graphics this.new_draw_node = newNode.getComponent(cc.Graphics); if (!this.new_draw_node) { this.new_draw_node = this.node.addComponent(cc.Graphics); } this.new_draw_node.clear(); // 清除以前的 this.new_draw_node.moveTo(xpos, ypos); this.new_draw_node.lineTo(xpos + 1, ypos + 1); this.new_draw_node.stroke();
3、返回该向量的长度 cc.pLength(vec1) ---> vec1.mag()
4、创建一个vector2向量cc.p(x, y) ---> cc.v2(x, y)
5、修改深度setLocalZOrder ---> node.zIndex = number 值越小越靠前
-------------------------- Editor
1、项目路径 Editor.projectPath ----> Editor.Project.path