zoukankan      html  css  js  c++  java
  • 白鹭(1)-创建公共样式

    // 加载图片公共类
    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;
        
    }
  • 相关阅读:
    【luogu】P1772物流运输(最短路+DP)
    【Bzoj】1001狼抓兔子(平面图最小割转对偶图最短路)
    后记
    【Luogu】P2680运输计划(树上差分+二分)
    【Luogu】P2059卡牌游戏(概率DP)
    【Luogu】P2051中国象棋(DP)
    概率与期望学习笔记
    【Luogu】P2894酒店Hotel(线段树)
    21.Mysql Server优化
    20.Mysql锁机制
  • 原文地址:https://www.cnblogs.com/LWJ-booke/p/7310906.html
Copyright © 2011-2022 走看看