游戲開發-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