创建全局常量类
[mw_shl_code=applescript,true]/**常用常量类 */
class GameConst {
/**舞台宽度 */
public static StageW:number;
/**舞台高度 */
public static StageH:number;
/**根据名字创建位图 */
public static CreateBitmapByName(name:string):egret.Bitmap {
let texture:egret.Texture = RES.getRes(name);
let bitmap:egret.Bitmap = new egret.Bitmap(texture);
return bitmap;
}
/**
* 根据name关键字创建一个Bitmap对象。此name 是根据TexturePacker 组合成的一张位图
*/
public static createBitmapFromSheet(name:string, sheetName:string):egret.Bitmap {
let texture:egret.Texture = RES.getRes(`${sheetName}_json.${name}`);
let result:egret.Bitmap = new egret.Bitmap(texture);
return result;
}
public static getTextureFromSheet(name:string, sheetName:string):egret.Texture {
let result:egret.Texture = RES.getRes(`${sheetName}_json.${name}`);
return result;
}
/**移除子类方法 */
public static removeChild(child:egret.DisplayObject) {
if(child && child.parent) {
if((<any>child.parent).removeElement) {
(<any>child.parent).removeElement(<any>(child));
}
else {
child.parent.removeChild(child);
}
}
}
}[/mw_shl_code]
作者:老A
来源:嘻吖仔
原文:http://www.xiaohewan.com/article/show?id=56
版权声明:本文为作者原创文章,转载请附上文章链接!