cc.Class({ extends: cc.Component, properties: { bgFrames: [cc.SpriteFrame], bgWrap: cc.Node }, onLoad () { let ran = Math.floor(cc.random0To1() * 3) this.bgWrap.getComponent(cc.Sprite).spriteFrame = this.bgFrames[ran]; }, });