cocos creater 面版设置node的zIndex

2019-05-12  本文已影响0人  凡凡的小web

原文链接[https://www.jianshu.com/p/f92e48467ce8]

/**
*SetZIndex.js 控制组件
**/
cc.Class({
    extends: cc.Component,
    //编辑器属性定义
    properties: {
        zIndex: {
            type: cc.Integer, //使用整型定义
            default: 0,
            //使用notify函数监听属性变化
            notify(oldValue) {
                //减少无效赋值
                if (oldValue === this.zIndex) {
                    return;
                }
                this.node.zIndex = this.zIndex;
            }
        }
    },
    onLoad () {
        this.node.zIndex = this.zIndex;
    }
});
上一篇 下一篇

猜你喜欢

热点阅读