creator-JS脚本结构介绍

//写在脚本外面的全局变量
cc.Class({
    extends: cc.Component,    //设置父类(脚本属于组件的子类)

    properties: {             //设置全局属性或者函数的地方,调用的时候要加this.可以直接把节点或者资源拖到脚本位置
        GameOver:{
            default:null,
            type: cc.Node     //设置属性的类型
        },
        GameSucc:{
            default:null,
            type: cc.Node
        },
    },

    start () {
        this.GameOver.active = false;      //设置this.GameOver的显隐,
        this.GameSucc.active = false;

    },
  
    update (dt) {   
    },
    //游戏失败的显示
    onGameOver () {
    },
    //游戏成功的显示
    onGameSucc () {

    },

});

猜你喜欢

转载自blog.csdn.net/Mihongzhong/article/details/89335067