修复触屏按虚拟按键爆炸
This commit is contained in:
@@ -53,7 +53,7 @@ function scene.touchMove()
|
|||||||
for i=#L,1,-1 do
|
for i=#L,1,-1 do
|
||||||
L[2*i-1],L[2*i]=SCR.xOy:inverseTransformPoint(tc.getPosition(L[i]))
|
L[2*i-1],L[2*i]=SCR.xOy:inverseTransformPoint(tc.getPosition(L[i]))
|
||||||
end
|
end
|
||||||
local keys=VK.getKeys
|
local keys=VK.keys
|
||||||
for n=1,#keys do
|
for n=1,#keys do
|
||||||
local B=keys[n]
|
local B=keys[n]
|
||||||
if B.ava then
|
if B.ava then
|
||||||
@@ -73,7 +73,7 @@ function scene.keyDown(key)
|
|||||||
if k>0 then
|
if k>0 then
|
||||||
if noKey then return end
|
if noKey then return end
|
||||||
PLAYERS[1]:pressKey(k)
|
PLAYERS[1]:pressKey(k)
|
||||||
local vk=VK.getKeys()[k]
|
local vk=VK.keys[k]
|
||||||
vk.isDown=true
|
vk.isDown=true
|
||||||
vk.pressTime=10
|
vk.pressTime=10
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ function scene.touchMove()
|
|||||||
for i=#L,1,-1 do
|
for i=#L,1,-1 do
|
||||||
L[2*i-1],L[2*i]=SCR.xOy:inverseTransformPoint(tc.getPosition(L[i]))
|
L[2*i-1],L[2*i]=SCR.xOy:inverseTransformPoint(tc.getPosition(L[i]))
|
||||||
end
|
end
|
||||||
local keys=VK.getKeys
|
local keys=VK.keys
|
||||||
for n=1,#keys do
|
for n=1,#keys do
|
||||||
local B=keys[n]
|
local B=keys[n]
|
||||||
if B.ava then
|
if B.ava then
|
||||||
@@ -86,7 +86,7 @@ function scene.keyDown(key)
|
|||||||
local k=keyMap.keyboard[key]
|
local k=keyMap.keyboard[key]
|
||||||
if k and k>0 then
|
if k and k>0 then
|
||||||
PLAYERS[1]:pressKey(k)
|
PLAYERS[1]:pressKey(k)
|
||||||
local vk=VK.getKeys()[k]
|
local vk=VK.keys[k]
|
||||||
vk.isDown=true
|
vk.isDown=true
|
||||||
vk.pressTime=10
|
vk.pressTime=10
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -5,9 +5,7 @@ for i=1,#VK_org do keys[i]={}end--In-game virtualkey layout
|
|||||||
|
|
||||||
local VK={}
|
local VK={}
|
||||||
|
|
||||||
function VK.getKeys()
|
VK.keys=keys
|
||||||
return keys
|
|
||||||
end
|
|
||||||
|
|
||||||
function VK.on(x,y)
|
function VK.on(x,y)
|
||||||
local dist,nearest=1e10
|
local dist,nearest=1e10
|
||||||
@@ -108,16 +106,28 @@ function VK.draw()
|
|||||||
for i=1,#keys do
|
for i=1,#keys do
|
||||||
if keys[i].ava then
|
if keys[i].ava then
|
||||||
local B=keys[i]
|
local B=keys[i]
|
||||||
|
|
||||||
|
--Button outline
|
||||||
gc_setColor(1,1,1,a)
|
gc_setColor(1,1,1,a)
|
||||||
gc_setLineWidth(B.r*.07)
|
gc_setLineWidth(B.r*.07)
|
||||||
gc_circle("line",B.x,B.y,B.r,10)--Button outline
|
gc_circle("line",B.x,B.y,B.r,10)
|
||||||
|
|
||||||
|
--Icon
|
||||||
_=keys[i].pressTime
|
_=keys[i].pressTime
|
||||||
gc_setColor(B.color[1],B.color[2],B.color[3],a)
|
local c=B.color
|
||||||
gc_draw(icons[i],B.x,B.y,nil,B.r*.026+_*.08,nil,18,18)--Icon
|
gc_setColor(c[1],c[2],c[3],a)
|
||||||
|
gc_draw(icons[i],B.x,B.y,nil,B.r*.026+_*.08,nil,18,18)
|
||||||
|
|
||||||
|
--Ripple
|
||||||
if _>0 then
|
if _>0 then
|
||||||
gc_setColor(1,1,1,a*_*.08)
|
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)
|
||||||
gc_circle("line",B.x,B.y,B.r*(1.4-_*.04),10)--Ripple
|
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
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user