// Learn TypeScript: // - https://docs.cocos.com/creator/manual/en/scripting/typescript.html // Learn Attribute: // - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html // Learn life-cycle callbacks: // - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html const {ccclass, property} = cc._decorator; @ccclass export default class NewClass extends cc.Component { @property(cc.Label) label: cc.Label = null; @property text: string = 'hello'; btnStatic: number = 0; propName: string = ""; // LIFE-CYCLE CALLBACKS: // onLoad () {} start () { for(let i=0; i { if (err) { console.error('动态加载背景图失败:', err); return; } this.node.getChildByName("icon").getComponent(cc.Sprite).spriteFrame = spriteFrame; }) break; } } } setMode(mode:number){ this.btnStatic = mode; let name = "GameScene"; if(mode == 1){ name = "HomeScene"; } cc.director.preloadScene(name, ()=>{ }) } clickBtn(){ cc.fx.AudioManager._instance.playEffect("anniu_Big",null); if(this.btnStatic == 1){ cc.director.loadScene("HomeScene"); } else if(this.btnStatic == 2){ cc.director.loadScene("GameScene"); } } // update (dt) {} }