Alpha V0.2
This commit is contained in:
99
control.lua
99
control.lua
@@ -1,5 +1,4 @@
|
||||
function buttonControl_key(i)
|
||||
mouseShow=false
|
||||
if i=="up"or i=="down"or i=="left"or i=="right"then
|
||||
if not Buttons.sel then
|
||||
Buttons.sel=1
|
||||
@@ -14,10 +13,10 @@ function buttonControl_key(i)
|
||||
sysSFX("button")
|
||||
end
|
||||
end
|
||||
mouseShow=false
|
||||
end
|
||||
function buttonControl_gamepad(i)
|
||||
if i=="dpup"or i=="dpdown"or i=="dpleft"or i=="dpright"then
|
||||
|
||||
if not Buttons.sel then
|
||||
Buttons.sel=1
|
||||
mouseShow=false
|
||||
@@ -27,65 +26,91 @@ function buttonControl_gamepad(i)
|
||||
elseif i=="start"then
|
||||
if not sceneSwaping and Buttons.sel then
|
||||
local B=Buttons[scene][Buttons.sel]
|
||||
if B.hold then Buttons.pressing=max(Buttons.pressing,1)end
|
||||
B.code()
|
||||
B.alpha=1
|
||||
sysSFX("button")
|
||||
end
|
||||
end
|
||||
mouseShow=false
|
||||
end
|
||||
|
||||
function love.mousemoved(x,y)
|
||||
mouseShow=true
|
||||
mx,my=mouseConvert(x,y)
|
||||
Buttons.sel=nil
|
||||
for i=1,#Buttons[scene]do
|
||||
local B=Buttons[scene][i]
|
||||
if not(B.hide and B.hide())then
|
||||
if abs(mx-B.x)<B.w*.5 and abs(my-B.y)<B.h*.5 then
|
||||
Buttons.sel=i
|
||||
return nil
|
||||
function love.mousemoved(x,y,dx,dy,t)
|
||||
if not t then
|
||||
mouseShow=true
|
||||
mx,my=convert(x,y)
|
||||
Buttons.sel=nil
|
||||
for i=1,#Buttons[scene]do
|
||||
local B=Buttons[scene][i]
|
||||
if not(B.hide and B.hide())then
|
||||
if abs(mx-B.x)<B.w*.5 and abs(my-B.y)<B.h*.5 then
|
||||
Buttons.sel=i
|
||||
return nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if not Buttons.sel then Buttons.pressing=0 end
|
||||
end
|
||||
function love.mousepressed(x,y,k)
|
||||
mouseShow=true
|
||||
mx,my=mouseConvert(x,y)
|
||||
if mouseDown[scene]then mouseDown[scene](mx,my,k)end
|
||||
if k==1 then
|
||||
if not sceneSwaping and Buttons.sel then
|
||||
local B=Buttons[scene][Buttons.sel]
|
||||
if B.hold then Buttons.pressing=max(Buttons.pressing,1)end
|
||||
B.code()
|
||||
B.alpha=1
|
||||
Buttons.sel=nil
|
||||
love.mousemoved(x,y)
|
||||
sysSFX("button")
|
||||
function love.mousepressed(x,y,k,t,num)
|
||||
if not t then
|
||||
mouseShow=true
|
||||
mx,my=convert(x,y)
|
||||
if mouseDown[scene]then mouseDown[scene](mx,my,k)end
|
||||
if k==1 then
|
||||
if not sceneSwaping and Buttons.sel then
|
||||
local B=Buttons[scene][Buttons.sel]
|
||||
B.code()
|
||||
B.alpha=1
|
||||
Buttons.sel=nil
|
||||
love.mousemoved(x,y)
|
||||
sysSFX("button")
|
||||
end
|
||||
elseif k==3 then
|
||||
back()
|
||||
end
|
||||
elseif k==3 then
|
||||
back()
|
||||
end
|
||||
end
|
||||
function love.mousereleased(x,y,k)
|
||||
Buttons.pressing=0
|
||||
function love.mousereleased(x,y,k,t,num)
|
||||
end
|
||||
|
||||
function love.touchpressed(id,x,y)
|
||||
ins(touches,id)
|
||||
if not touching then
|
||||
touching=id
|
||||
love.mousemoved(x,y)
|
||||
end
|
||||
mouseShow=false
|
||||
end
|
||||
function love.touchrealeased(id,x,y)
|
||||
for i=1,#touches do
|
||||
if touches[i]==id then rem(touches,i)break end
|
||||
function love.touchreleased(id,x,y)
|
||||
if id==touching then
|
||||
touching=nil
|
||||
if Buttons.sel then
|
||||
local B=Buttons[scene][Buttons.sel]
|
||||
B.code()
|
||||
B.alpha=1
|
||||
Buttons.sel=nil
|
||||
end
|
||||
Buttons.sel=nil
|
||||
mouseShow=false
|
||||
end
|
||||
if scene=="play"and #tc.getTouches()==0 then
|
||||
for K=1,#gamepad do
|
||||
if gamepad[K].press then
|
||||
releaseKey(K)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
function love.touchmoved(id,x,y,dx,dy)
|
||||
love.mousemoved(x,y)
|
||||
mouseShow=false
|
||||
if not Buttons.sel then
|
||||
touching=nil
|
||||
end
|
||||
end
|
||||
|
||||
function love.keypressed(i)
|
||||
if keyDown[scene]then keyDown[scene](i)
|
||||
elseif i=="escape"then back()
|
||||
elseif i=="escape"or i=="back"then back()
|
||||
else buttonControl_key(i)
|
||||
end
|
||||
end
|
||||
@@ -106,7 +131,6 @@ function love.gamepadpressed(joystick,i)
|
||||
elseif i=="start"then
|
||||
if not sceneSwaping and Buttons.sel then
|
||||
local B=Buttons[scene][Buttons.sel]
|
||||
if B.hold then Buttons.pressing=max(Buttons.pressing,1)end
|
||||
B.code()
|
||||
B.alpha=1
|
||||
sysSFX("button")
|
||||
@@ -115,6 +139,7 @@ function love.gamepadpressed(joystick,i)
|
||||
end
|
||||
if gamepadDown[scene]then return gamepadDown[scene](i)
|
||||
elseif i=="back"then return back()
|
||||
else buttonControl_gamepad(i)
|
||||
end
|
||||
end
|
||||
function love.gamepadreleased(joystick,i)
|
||||
|
||||
Reference in New Issue
Block a user