模式地图支持按住ctrl或alt后方向键功能变为缩放 close #101

This commit is contained in:
MrZ626
2021-07-06 21:05:24 +08:00
parent f3d8c6b98a
commit 5ceb59daae

View File

@@ -159,22 +159,26 @@ function scene.update()
end
if F then
mapCam.keyCtrl=true
moveMap(dx,dy)
local x,y=getPos()
for name,M in next,MODES do
if RANKS[name]and M.x then
local SEL
local s=M.size
if M.shape==1 then
if x>M.x-s and x<M.x+s and y>M.y-s and y<M.y+s then SEL=name end
elseif M.shape==2 then
if abs(x-M.x)+abs(y-M.y)<s then SEL=name end
elseif M.shape==3 then
if(x-M.x)^2+(y-M.y)^2<s^2 then SEL=name end
end
if SEL and mapCam.sel~=SEL then
mapCam.sel=SEL
SFX.play('click')
if kb.isDown("lctrl","rctrl","lalt","ralt")then
scene.wheelMoved(nil,(dy-dx)*.026)
else
moveMap(dx,dy)
local x,y=getPos()
for name,M in next,MODES do
if RANKS[name]and M.x then
local SEL
local s=M.size
if M.shape==1 then
if x>M.x-s and x<M.x+s and y>M.y-s and y<M.y+s then SEL=name end
elseif M.shape==2 then
if abs(x-M.x)+abs(y-M.y)<s then SEL=name end
elseif M.shape==3 then
if(x-M.x)^2+(y-M.y)^2<s^2 then SEL=name end
end
if SEL and mapCam.sel~=SEL then
mapCam.sel=SEL
SFX.play('click')
end
end
end
end