删除虚拟按键颜色,恢复最早的白色
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
local gc=love.graphics
|
||||
|
||||
local SETTING=SETTING
|
||||
local next=next
|
||||
local SETTING,TIME=SETTING,TIME
|
||||
local VK_org=VK_org
|
||||
|
||||
--Virtualkey icons
|
||||
local VKIcon={}
|
||||
@@ -17,13 +18,12 @@ local VK={keys=keys}
|
||||
|
||||
function VK.on(x,y)
|
||||
local dist,nearest=1e10
|
||||
for K=1,#keys do
|
||||
local B=keys[K]
|
||||
for id,B in next,keys do
|
||||
if B.ava then
|
||||
local d1=(x-B.x)^2+(y-B.y)^2
|
||||
if d1<B.r^2 then
|
||||
if d1<dist then
|
||||
nearest,dist=K,d1
|
||||
nearest,dist=id,d1
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -47,8 +47,7 @@ function VK.touch(id,x,y)
|
||||
|
||||
--Button collision (not accurate)
|
||||
if SETTING.VKDodge then
|
||||
for i=1,#keys do
|
||||
local b=keys[i]
|
||||
for _,b in next,keys do
|
||||
local d=B.r+b.r-((B.x-b.x)^2+(B.y-b.y)^2)^.5--Hit depth(Neg means distance)
|
||||
if d>0 then
|
||||
b.x=b.x+(b.x-B.x)*d*b.r*2.6e-5
|
||||
@@ -81,23 +80,21 @@ function VK.restore()
|
||||
B.x=O.x
|
||||
B.y=O.y
|
||||
B.r=O.r
|
||||
B.color=O.color
|
||||
B.isDown=false
|
||||
B.pressTime=0
|
||||
end
|
||||
for k,v in next,PLAYERS[1].keyAvailable do
|
||||
for id,v in next,PLAYERS[1].keyAvailable do
|
||||
if not v then
|
||||
keys[k].ava=false
|
||||
keys[id].ava=false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function VK.update()
|
||||
if SETTING.VKSwitch then
|
||||
for i=1,#keys do
|
||||
local _=keys[i]
|
||||
if _.pressTime>0 then
|
||||
_.pressTime=_.pressTime-1
|
||||
for _,B in next,keys do
|
||||
if B.pressTime>0 then
|
||||
B.pressTime=B.pressTime-1
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -105,72 +102,64 @@ end
|
||||
|
||||
local gc_circle,gc_draw,gc_setColor,gc_setLineWidth=gc.circle,gc.draw,gc.setColor,gc.setLineWidth
|
||||
function VK.draw()
|
||||
if SETTING.VKSwitch then
|
||||
local a=SETTING.VKAlpha
|
||||
if SETTING.VKIcon then
|
||||
for i=1,#keys do
|
||||
if keys[i].ava then
|
||||
local B=keys[i]
|
||||
if not SETTING.VKSwitch then return end
|
||||
local a=SETTING.VKAlpha
|
||||
if SETTING.VKIcon then
|
||||
for i,B in next,keys do
|
||||
if B.ava then
|
||||
--Button outline
|
||||
gc_setColor(1,1,1,a)
|
||||
gc_setLineWidth(B.r*.07)
|
||||
gc_circle('line',B.x,B.y,B.r,10)
|
||||
|
||||
--Button outline
|
||||
gc_setColor(1,1,1,a)
|
||||
gc_setLineWidth(B.r*.07)
|
||||
gc_circle('line',B.x,B.y,B.r,10)
|
||||
--Icon
|
||||
local _=B.pressTime
|
||||
gc_setColor(1,1,1,a)
|
||||
gc_draw(VKIcon[i],B.x,B.y,nil,B.r*.026+_*.08,nil,18,18)
|
||||
|
||||
--Icon
|
||||
local _=keys[i].pressTime
|
||||
local c=B.color
|
||||
gc_setColor(c[1],c[2],c[3],a)
|
||||
gc_draw(VKIcon[i],B.x,B.y,nil,B.r*.026+_*.08,nil,18,18)
|
||||
--Ripple
|
||||
if _>0 then
|
||||
gc_setColor(1,1,1,a*_*.08)
|
||||
gc_circle('line',B.x,B.y,B.r*(1.4-_*.04),10)
|
||||
end
|
||||
|
||||
--Ripple
|
||||
if _>0 then
|
||||
gc_setColor(1,1,1,a*_*.08)
|
||||
gc_circle('line',B.x,B.y,B.r*(1.4-_*.04),10)
|
||||
end
|
||||
|
||||
--Glow when press
|
||||
if B.isDown then
|
||||
gc_setColor(1,1,1,a*.4)
|
||||
gc_circle('fill',B.x,B.y,B.r*.94,10)
|
||||
end
|
||||
--Glow when press
|
||||
if B.isDown then
|
||||
gc_setColor(1,1,1,a*.4)
|
||||
gc_circle('fill',B.x,B.y,B.r*.94,10)
|
||||
end
|
||||
end
|
||||
else
|
||||
for i=1,#keys do
|
||||
if keys[i].ava then
|
||||
local B=keys[i]
|
||||
gc_setColor(1,1,1,a)
|
||||
gc_setLineWidth(B.r*.07)
|
||||
gc_circle('line',B.x,B.y,B.r,10)
|
||||
local _=keys[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
|
||||
else
|
||||
for _,B in next,keys do
|
||||
if B.ava then
|
||||
gc_setColor(1,1,1,a)
|
||||
gc_setLineWidth(B.r*.07)
|
||||
gc_circle('line',B.x,B.y,B.r,10)
|
||||
local _=B.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
|
||||
function VK.preview(selected)
|
||||
if SETTING.VKSwitch then
|
||||
for i=1,#VK_org do
|
||||
local B=VK_org[i]
|
||||
if B.ava then
|
||||
if not SETTING.VKSwitch then return end
|
||||
for id,B in next,VK_org do
|
||||
if B.ava then
|
||||
gc_setColor(1,1,1,SETTING.VKAlpha)
|
||||
gc_setLineWidth(B.r*.07)
|
||||
gc_circle('line',B.x,B.y,B.r,10)
|
||||
if selected==id and TIME()%.26<.13 then
|
||||
gc_setColor(1,1,1,SETTING.VKAlpha*.62)
|
||||
gc_circle('fill',B.x,B.y,B.r,10)
|
||||
end
|
||||
if SETTING.VKIcon then
|
||||
gc_setColor(1,1,1,SETTING.VKAlpha)
|
||||
gc_setLineWidth(B.r*.07)
|
||||
gc_circle('line',B.x,B.y,B.r,10)
|
||||
if selected==i and TIME()%.26<.13 then
|
||||
gc_setColor(1,1,1,SETTING.VKAlpha*.62)
|
||||
gc_circle('fill',B.x,B.y,B.r,10)
|
||||
end
|
||||
if SETTING.VKIcon then
|
||||
local c=B.color
|
||||
gc_setColor(c[1],c[2],c[3],SETTING.VKAlpha)
|
||||
gc_draw(VKIcon[i],B.x,B.y,nil,B.r*.025,nil,18,18)
|
||||
end
|
||||
gc_draw(VKIcon[id],B.x,B.y,nil,B.r*.025,nil,18,18)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user