cocos-creator 初学篇(一)

cc.Class({
    extends: cc.Component,

    properties: {
        label: {
            default: null,
            type: cc.Label
        },
        // defaults, set visually when attaching this script to the Canvas
        text: 'World!',
        money:{             //需要默认值,
            default:0,
            displayName:"我的娘啊"
        },
        MySpriteFrame:{     //设置图片帧,一定需要默认值,需要用null
            default:null,
            type:cc.SpriteFrame
        },
        names:[cc.Integer],//定义一个数组
        CVect:cc.Vec2,      //数组


        myfuctis:{              //获取访问器
            get:function(){
                console.log(this.money);
                console.log("获取到了money");
                return this.money;
            },
            set:function(v){    //设置访问器
                this.money=v;
                console.log("设置了money");
                return v;
            }
        }
    },

    // use this for initialization
    onLoad: function () {
        this.label.string = "fuccccccccccckerrrrrrr";
        var myson=new son();
        son.money=365214;
        console.log("son.money="+son.money);
        console.log(this.myfuctis);
        this.myfuctis=3.14159;
    },

    // called every frame
    update: function (dt) {

    },
});

var Parent =cc.Class(       //这是父类
    {
        ctor:function()
        {
            this.money=100;
            console.log('666666');  
        }
    }
);

var son=cc.Class({          //这是子类
    extends:Parent,
    ctor:function()
    {
        console.log('son')
    }
});

 

你可能感兴趣的:(Cocos-creator)