// 数字标签 cc.Class({ extends: cc.Component, properties: { frames: { default: [], type: [cc.SpriteFrame], // type 同样写成数组,提高代码可读性 } }, // LIFE-CYCLE CALLBACKS: onLoad () { this.sprite = this.getComponent(cc.Sprite); this.value = 0; }, start () { }, // 外部调用 // 添加内容 updateValue:function() { // 给Sprite显示数据 var self = this; this.sprite.spriteFrame = this.frames[this.value]; // cc.loader.loadRes("nums/num_" + this.value, cc.SpriteFrame, function(err, spriteFrame) { // self.sprite.spriteFrame = spriteFrame; // cc.log("chak 值为 " + self.value); // }); } // update (dt) {}, });