globle.js
cc.Class({
extends: cc.Component,
properties: {
aa:555,
getDis:function(p1, p2) {
var x = p1.x - p2.x;
var y = p1.y - p2.y;
var dis = Math.pow((x * x + y * y), 0.5);
return dis;
},
},
利用require获取
var globle = require(‘globle’);
globle.aa += 20;
globle.getDis(p1,p2);//这里提示“Object doesn’t support property or method ‘getDis’
为什么这里只能获取到那个aa属性,而方法属性不能使用啦,像这样的公共函数该怎么写哟,求大神指点
});