今天編寫代碼遇到這個坑,很久沒有用cocos,api變了好多。
首先我們不能
this.timeLabe.setPosition(cc.v2(100,100));
直接設置其位置,而需要在此之前添加如下代碼
this.timeLabe = cc.find("Canvas/time");
需要通過路徑找到節點。
———————————————————————————————
其次,設置屬性也不能直接設置,而是通過如下方式:
this.timeLabe.getComponent(cc.Label).string = "倒計時";
誒,先這樣吧!