游戏开发-cocos creator踩坑-1.X版本引擎升级2.X后函数替换的问题

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)

猜你喜欢

转载自www.cnblogs.com/orxx/p/10552651.html