优化绘制虚拟按键的代码
This commit is contained in:
@@ -2,6 +2,9 @@ local tm=love.timer
|
||||
local data=love.data
|
||||
|
||||
local fs=love.filesystem
|
||||
local gc=love.graphics
|
||||
local gc_setColor,gc_circle=gc.setColor,gc.circle
|
||||
|
||||
local int,rnd=math.floor,math.random
|
||||
local sub=string.sub
|
||||
local char,byte=string.char,string.byte
|
||||
@@ -358,6 +361,50 @@ end
|
||||
|
||||
|
||||
|
||||
--Game draw
|
||||
local VK=virtualkey
|
||||
function drawVirtualKeys()
|
||||
if SETTING.VKSwitch then
|
||||
local a=SETTING.VKAlpha
|
||||
local _
|
||||
if SETTING.VKIcon then
|
||||
local icons=TEXTURE.VKIcon
|
||||
for i=1,#VK do
|
||||
if VK[i].ava then
|
||||
local B=VK[i]
|
||||
gc_setColor(1,1,1,a)
|
||||
gc.setLineWidth(B.r*.07)
|
||||
gc_circle("line",B.x,B.y,B.r,10)--Button outline
|
||||
_=VK[i].pressTime
|
||||
gc_setColor(B.color[1],B.color[2],B.color[3],a)
|
||||
gc.draw(icons[i],B.x,B.y,nil,B.r*.026+_*.08,nil,18,18)--Icon
|
||||
if _>0 then
|
||||
gc_setColor(1,1,1,a*_*.08)
|
||||
gc_circle("fill",B.x,B.y,B.r*.94,10)--Glow when press
|
||||
gc_circle("line",B.x,B.y,B.r*(1.4-_*.04),10)--Ripple
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
for i=1,#VK do
|
||||
if VK[i].ava then
|
||||
local B=VK[i]
|
||||
gc_setColor(1,1,1,a)
|
||||
gc.setLineWidth(B.r*.07)
|
||||
gc_circle("line",B.x,B.y,B.r,10)
|
||||
_=VK[i].pressTime
|
||||
if _>0 then
|
||||
gc_setColor(1,1,1,a*_*.08)
|
||||
gc_circle("fill",B.x,B.y,B.r*.94,10)
|
||||
gc_circle("line",B.x,B.y,B.r*(1.4-_*.04),10)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--Game
|
||||
function generateLine(hole)
|
||||
-- return 2^10-1-2^(hole-1)
|
||||
|
||||
Reference in New Issue
Block a user