如题。最近使用cocs creator ,在使用过程中遇到不少的问题,先整理一些下来,不定时更新。
1、label的显示 一直很纳闷,后台log出来有内容,就是UI上不显示。多方百度,逛论坛才知道,应该再去获取一遍
this.label = this.node.getCompoent(cc.Lable) ----就是少了这个获取,UI一直没显示想要的内容
this.label.string = "===";
如此一来,才会显示设置的的字符串内容
2、action
runAction 播放指定动作
序列动作sequence 播放指定的动作序列。可播放多个
moveBy 与 moveTo
3、监控用户行为
计时器有时候并不是最好的方法,有时候只要一个变量就可以了。项目可以参考像素鸟的制作。
--》像素鸟教程。。。。
4、背景的无限循环
实际上就是背景移动出舞台后的位置变化。
5、//动态更换精灵
changeTexture: function (str) {
var sprite = this.player.getComponent(cc.Sprite);
var url = cc.url.raw("resources/" + str + ".png");
var texture = cc.textureCache.addImage(url);
sprite.spriteFrame.setTexture(texture);
},