Files
Techmino/parts/scenes/app_piano.lua
MrZ626 941b875afa 再微调语言设置界面
整理代码
2021-12-07 01:05:46 +08:00

54 lines
1.6 KiB
Lua

local gc=love.graphics
local kb=love.keyboard
local instList={'lead','bell','bass'}
local keys={
['1']=61,['2']=63,['3']=65,['4']=66,['5']=68,['6']=70,['7']=72,['8']=73,['9']=75,['0']=77,['-']=78,['=']=80,['backspace']=82,
['q']=49,['w']=51,['e']=53,['r']=54,['t']=56,['y']=58,['u']=60,['i']=61,['o']=63,['p']=65,['[']=66,[']']=68,['\\']=70,
['a']=37,['s']=39,['d']=41,['f']=42,['g']=44,['h']=46,['j']=48,['k']=49,['l']=51,[';']=53,["'"]=54,['return']=56,
['z']=25,['x']=27,['c']=29,['v']=30,['b']=32,['n']=34,['m']=36,[',']=37,['.']=39,['/']=41,
}
local inst
local offset
local scene={}
function scene.sceneInit()
inst='lead'
offset=0
end
function scene.touchDown(x,y,k)
--TODO
end
scene.mouseDown=scene.touchDown
function scene.keyDown(key,isRep)
if not isRep and keys[key]then
local note=keys[key]+offset
if kb.isDown('lshift','rshift')then note=note+1 end
if kb.isDown('lctrl','rctrl')then note=note-1 end
SFX.playSample(inst,note)
TEXT.show(SFX.getNoteName(note),math.random(150,1130),math.random(140,500),60,'score',.8)
elseif key=='tab'then
inst=TABLE.next(instList,inst)
elseif key=='lalt'then
offset=math.max(offset-1,-12)
elseif key=='ralt'then
offset=math.min(offset+1,12)
elseif key=='escape'then
SCN.back()
end
end
function scene.draw()
setFont(30)
gc.print(inst,40,60)
gc.print(offset,40,100)
end
scene.widgetList={
WIDGET.newButton{name='back', x=1140,y=640,w=170,h=80,sound='back',font=60,fText=CHAR.icon.back,code=backScene},
}
return scene