 
                                    编写小车翻车后。加载复活页面


        loader.loadRes("views/OverCanvas", Prefab, (err: any, prefab: Prefab) => {
            if (err) {
                console.warn(err);
                return;
            }
            let node: Node |null  = null ;//这里之前用的不是let  小车没有回收。
            node = instantiate(prefab) as Node;
            this.node.parent.scene.addChild(node);
        });注:这个加载资源可以优化。后期加上优化。
 
import { _decorator, Component, Node, Button } from 'cc';
import { GameCtl } from '../GameCtl';
const { ccclass, property } = _decorator;
 
@ccclass('OverView')
export class OverView extends Component {
    @property({
        type: Button
    })
    recycle_btn: Button = null;
    @property({
        type: Button
    })
    no_btn: Button = null;
    start(){
        this.recycle_btn.node.on("click",this.recycle_click,this);
        this.no_btn.node.on("click",this.no_click,this);
    }
    
    recycle_click(){
        GameCtl._instance.player.reborn();
        this.node.destroy();//复活的页面。销毁
    }
    no_click(){
    }
}







站长微信:xiaomao0055
站长QQ:14496453