游戏开发-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)

5、修改深度setLocalZOrder ---> node.zIndex = number 值越小越靠前

 

 

 

 

 

 

 

-------------------------- Editor

1、项目路径 Editor.projectPath ---->  Editor.Project.path


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM