cocos creator关于Label位置动态设置以及属性编辑的问题

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Ling_cmd/article/details/84630408

今天编写代码遇到这个坑,很久没有用cocos,api变了好多。

首先我们不能

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

直接设置其位置,而需要在此之前添加如下代码

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

需要通过路径找到节点。

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

其次,设置属性也不能直接设置,而是通过如下方式:

this.timeLabe.getComponent(cc.Label).string = "倒计时";

诶,先这样吧!

猜你喜欢

转载自blog.csdn.net/Ling_cmd/article/details/84630408
今日推荐