1. 程式人生 > >cocos creator關於Label位置動態設定以及屬性編輯的問題

cocos creator關於Label位置動態設定以及屬性編輯的問題

今天編寫程式碼遇到這個坑,很久沒有用cocos,api變了好多。

首先我們不能

this.timeLabe.setPosition(cc.v2(100,100));

直接設定其位置,而需要在此之前新增如下程式碼

this.timeLabe = cc.find("Canvas/time");

需要通過路徑找到節點。

———————————————————————————————

其次,設定屬性也不能直接設定,而是通過如下方式:

this.timeLabe.getComponent(cc.Label).string = "倒計時";

誒,先這樣吧!