// 加载图片公共类
function createImg(name){//图片名字
let result =new egret.Bitmap();
result.texture=RES.getRes(name);
return result;
}
// 按钮公共类
function createBtn(x,y,bgColor,activeBgcolor, btnwidth,btnheight,btntext,textsize,textcolor,eliscWidth,eliscHeight,callback=function(){}){
let result=new egret.Sprite();
result.x=x;
result.y=y;
let shap=new egret.Shape();
result.addChild(shap);
shap.graphics.beginFill(bgColor);
shap.graphics.drawRoundRect(0,0,btnwidth,btnheight,eliscWidth,eliscHeight);
shap.graphics.endFill();
let text=new egret.TextField();
result.addChild(text);
text.text=btntext;
text.width=btnwidth;
text.height=btnheight;
text.size=textsize;
text.textColor=textcolor;
text.textAlign=egret.HorizontalAlign.CENTER;
text.verticalAlign=egret.VerticalAlign.MIDDLE;
//添加点击事件
shap.touchEnabled=true;
shap.addEventListener(egret.TouchEvent.TOUCH_BEGIN,function(){
shap.graphics.clear();
shap.graphics.beginFill(activeBgcolor);
shap.graphics.drawRoundRect(0,0,btnwidth,btnheight,eliscWidth,eliscHeight);
shap.graphics.endFill();
},shap);
//添加结束事件
shap.addEventListener(egret.TouchEvent.TOUCH_END,function(){
shap.graphics.clear();
shap.graphics.beginFill(bgColor);
shap.graphics.drawRoundRect(0,0,btnwidth,btnheight,eliscWidth,eliscHeight);
shap.graphics.endFill();
callback();
},shap);
shap.addEventListener(egret.TouchEvent.TOUCH_RELEASE_OUTSIDE,function(){
shap.graphics.clear();
shap.graphics.beginFill(bgColor);
shap.graphics.drawRoundRect(0,0,btnwidth,btnheight,eliscWidth,eliscHeight);
shap.graphics.endFill();
},shap);
return result;
}