CocosCreator实现文字逐个出现的打字机效果
程序员文章站
2022-06-22 20:01:37
...
typingAni: function (label, text, cb) {
var self = this;
var html = '';
var arr = text.split('');
var len = arr.length;
var step = 0;
self.func = function () {
html += arr[step];
label.string = html;
if (++step == len) {
self.unschedule(self.func, self);
cb && cb();
}
}
self.schedule(self.func,0.05, cc.macro.REPEAT_FOREVER, 0)
},