cc.Class({ extends: cc.Component, properties: { box: { default: null, type: cc.Sprite }, type: 'wood', status: 'c' }, // LIFE-CYCLE CALLBACKS: onLoad () { this.updateShow('c'); }, start () { }, // update (dt) {}, updateShow(status) { this.status = status; let url = `textures/part1/bar_cube_${this.type}_${this.status}`; let self = this; cc.loader.loadRes(url, cc.SpriteFrame, function (err, spriteFrame) { self.box.spriteFrame = spriteFrame; }); } });