联网对战房间内新增设置按钮,不离开房间就能修改设置(需要在未准备状态)

This commit is contained in:
MrZ626
2021-04-26 10:55:58 +08:00
parent 0b885d83af
commit e31caaeb65
3 changed files with 36 additions and 6 deletions

View File

@@ -198,16 +198,22 @@ end
function NET.checkPlayDisconn()
return WS.status("play")~="running"
end
function NET.signal_ready(ready)
if NET.lock("ready",3)and not NET.serverGaming then
WS.send("play",'{"action":6,"data":{"ready":'..tostring(ready)..'}}')
end
end
function NET.signal_quit()
if NET.lock("quit",3)then
WS.send("play",'{"action":3}')
end
end
function NET.sendMessage(mes)
WS.send("play",'{"action":4,"data":{"message":'..mes..'}}')
end
function NET.changeConfig()
WS.send("play",'{"action":5,"data":'..JSON.encode({config=dumpBasicConfig()})..'}')
end
function NET.signal_ready(ready)
if NET.lock("ready",3)and not NET.serverGaming then
WS.send("play",'{"action":6,"data":{"ready":'..tostring(ready)..'}}')
end
end
function NET.signal_die()
WS.send("stream",'{"action":4,"data":{"score":0,"survivalTime":0}}')
end

View File

@@ -16,7 +16,7 @@ local scene={}
function scene.sceneBack()
love.keyboard.setKeyRepeat(true)
end
function scene.sceneInit()
function scene.sceneInit(org)
love.keyboard.setKeyRepeat(false)
textBox.hide=true
textBox:clear()
@@ -25,6 +25,10 @@ function scene.sceneInit()
playing=false
lastUpstreamTime=0
upstreamProgress=1
if org=="setting_game"then
NET.changeConfig()
end
end
scene.mouseDown=NULL
@@ -88,6 +92,10 @@ function scene.keyDown(key)
end
elseif key=="space"then
NET.signal_ready(not PLY_NET[1].ready)
elseif key=="s"then
if not PLY_NET[1].ready then
SCN.go("setting_game")
end
end
end
function scene.keyUp(key)
@@ -274,6 +282,7 @@ function scene.draw()
end
scene.widgetList={
textBox,
WIDGET.newKey{name="setting",fText=TEXTURE.setting,x=1200,y=160,w=90,h=90,code=pressKey"s",hide=function()return PLY_NET[1].ready end},
WIDGET.newKey{name="ready",x=900,y=560,w=400,h=100,color="lB",font=40,code=pressKey"space",
hide=function()
return

View File

@@ -79,6 +79,7 @@ TEXTURE.cursor_hold=DOGC{16,16,
{"fCirc",8,8,3},
}
--Level icons
TEXTURE.lvIcon=setmetatable({},{__index=function(self,lv)
local img={25,25}
@@ -93,6 +94,20 @@ TEXTURE.lvIcon=setmetatable({},{__index=function(self,lv)
return img
end})
--Setting icon
TEXTURE.setting=DOGC{64,64,
{"setLW",8},
{"dCirc",32,32,18},
{"setLW",10},
{"dLine",52,32,64,32},
{"dLine",32,52,32,64},
{"dLine",12,32,0,32},
{"dLine",32,12,32,0},
{"dLine",45,45,55,55},
{"dLine",19,45,9,55},
{"dLine",19,19,9,9},
{"dLine",45,19,55,9},
}
gc.setDefaultFilter("linear","linear")