From c38ef7c487e5ba1a8d2298bb92fd6c062f2bb1b9 Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Sat, 21 Nov 2020 20:19:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E6=9C=AC=E6=8E=A7=E4=BB=B6=E5=8F=AF?= =?UTF-8?q?=E4=BB=A5=E6=B7=A1=E5=85=A5=E6=B7=A1=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Zframework/widget.lua | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/Zframework/widget.lua b/Zframework/widget.lua index 01b11f68..133ad5d9 100644 --- a/Zframework/widget.lua +++ b/Zframework/widget.lua @@ -19,6 +19,7 @@ local widgetMetatable={ local text={ type="text", + alpha=0, } function text:reset() if type(self.text)=="string"then @@ -29,14 +30,26 @@ function text:reset() self.font=self.font-10 end end +function text:update() + if self.hideCon and self.hideCon()then + if self.alpha>0 then + self.alpha=self.alpha-.125 + end + elseif self.alpha<1 then + self.alpha=self.alpha+.125 + end +end function text:draw() - gc.setColor(self.color) - if self.align=="M"then - gc.draw(self.text,self.x-self.text:getWidth()*.5,self.y) - elseif self.align=="L"then - gc.draw(self.text,self.x,self.y) - elseif self.align=="R"then - gc.draw(self.text,self.x-self.text:getWidth(),self.y) + if self.alpha>0 then + local c=self.color + gc.setColor(c[1],c[2],c[3],self.alpha) + if self.align=="M"then + gc.draw(self.text,self.x-self.text:getWidth()*.5,self.y) + elseif self.align=="L"then + gc.draw(self.text,self.x,self.y) + elseif self.align=="R"then + gc.draw(self.text,self.x-self.text:getWidth(),self.y) + end end end function WIDGET.newText(D)--name,x,y[,color][,font=30][,align="M"][,hide] @@ -47,9 +60,10 @@ function WIDGET.newText(D)--name,x,y[,color][,font=30][,align="M"][,hide] color= D.color and(COLOR[D.color]or D.color)or COLOR.white, font= D.font or 30, align= D.align or"M", - hide= D.hide, + hideCon=D.hide, } for k,v in next,text do _[k]=v end + if not _.hideCon then _.alpha=1 end setmetatable(_,widgetMetatable) return _ end