Read the document directly from the beginning using CC. class declaration type declaration of the class object that block forgot, and familiar with JS about the object description, (details visible http://www.w3school.com.cn/js/js_objects.asp) Then, about the constructor (HTTP/ www.cnblogs.com/iceknp/archive/2010/06/08/1753729.html), Get () set () (This is a typical understanding of the object-oriented opening and closing principle https://zhidao.baidu.com/ question/494920588281615924.html), a Java or C # base should be pro.
There are two main points that may be used in the future to inherit one or the other:
var Shape = cc. Class ({ctor:function () {Cc.log ("Shape"); When instantiated, the parent constructor is automatically called,}}); var Rect = cc. Class ({extends:shape}); var Square = cc. Class ({extends:rect, ctor:function () {Cc.log ("Square"); Call the sub-constructor}}); var square = new Square ();
Second, to declare attributes, only the CC is required. Class-defined properties
field, fill in the property name and attribute parameters, such as:
Cc. Class ({extends:cc.Component, properties: {userid:20, UserName: "Foobar"}});
Noon did not sleep, the afternoon suffers, today will come here,
This article is from the "12249049" blog, please be sure to keep this source http://12259049.blog.51cto.com/12249049/1870307
Cocos Creator self-learning experience------first day of scripting