zoukankan      html  css  js  c++  java
  • Egret动态设置按钮的图片

    参考:

    动态设置Button按钮的状态图片

    按钮有3个状态,up down disabled。这里区别于source,source.down,source.disabled,而是每个状态单独一个image。

    且每个单独的<image>标签有一个特别的属性includeIn,这里表示该图片的状态。

    	<e:RadioButton id="testBtn" label="" x="398" y="62" anchorOffsetX="0" width="142" anchorOffsetY="0" height="62">
    		<e:skinName>
    		<e:Skin states="up,down,disabled">
    			<e:Image width="100%" height="100%" source="book_scale1_0_png" includeIn="up" id="radio_pic_up"/>
    			<e:Image width="100%" height="100%" source="book_scale1_1_png" includeIn="down" id="radio_pic_down"/>
    			<e:Image width="100%" height="100%" source="book_scale1_2_png" includeIn="disabled" id="radio_pic_disabled"/>
    			<e:Label id="labelDisplay" horizontalCenter="0" verticalCenter="0"/>
    		</e:Skin>
    		</e:skinName>
    	</e:RadioButton>
    

     

    代码中根据图片id获取按钮的图片["radio_pic_up"],再赋值新的texture就可以动态改变按钮的图片了。

    this.testBtn["radio_pic_up"].texture = RES.getRes("0_png");
    this.testBtn["radio_pic_down"].texture = RES.getRes("1_png");
    this.testBtn["radio_pic_disabled"].texture = RES.getRes("2_png");
    

      

  • 相关阅读:
    Apache部署Django项目
    Docker
    常用算法
    Go之基本数据类型
    Go之流程控制
    Go基本使用
    Go安装与Goland破解永久版
    Linux
    详解java中的byte类型
    Linux统计文本中某个字符串出现的次数
  • 原文地址:https://www.cnblogs.com/gamedaybyday/p/9618037.html
Copyright © 2011-2022 走看看