js2dx根本语法

js2dx基本语法

 

1.先声明后使用,有顺序的

 

2.全局(引进文件的时候就执行了)

全局变量  var layerTestSceneIdx = -1;

全局方法  var nextLayerTest = function () { };   nextLayerTest()调用

 

 

3. 对象  new xxx以后在调用里面得方法

 

(0)数组 

var testNames = [  ...  ];

(1)普通对象

var VisibleRect = {

  title:function () {  方法},

};

 

(2)继承对象

var xxx = cc.XXX.extenr() ( {

 

   不是方法里变量 

   helloImg : null,   

   helloLabel:null,     控件对象里全局用都要先声明一下之后用 this.helloLabel = 赋值

 

   title:function () {  方法

   

       helloImg = 232;       

 

        return "No title";

    },最后一个不用,了

 

 

}  );

 

 

4.var 全能 function,false ,int ...

 

 

5.所有的控件如果操作复杂,都要继承(cc.XXX.extend({});)一下在添加到 layer 里