方法一:实例化一个类的对象,通过new方法
this.action = new FoxAni(parent);
方法二:单例化
private static _instance:PlayerService;
static get instance():PlayerService {
if (!this._instance) {
this._instance = new foxgame.PlayerService();
}
return this._instance;
}
调用: var entityMap = PlayerService.instance.getAllRoleEntities();
方法三:类的函数静态化:
1.变量静态 static isNewBeeWingdStep:boolean = false;
. 调用: Global. isNewBeeWingdStep;
2.函数静态 static getAttrName(attrId):string {
return LangManager.instance.getText("@AttrName_"+attrId);
}
调用: valStr = GameUtils.getAttrName(attr.attrId) + "+" + attr.attrValue;
方法四:声明一个类的对象,创建一个类的实例对象
private hunzhuControler:foxgame.HunZhuControler;
HunZhuControler这个类的方法需要设置为公共public方法。