diff --git a/parts/scenes/app_piano.lua b/parts/scenes/app_piano.lua index 4ef665a9d..87c859be1 100644 --- a/parts/scenes/app_piano.lua +++ b/parts/scenes/app_piano.lua @@ -12,111 +12,11 @@ local keys={ local lastPlayBGM local inst local offset +local tempoffset=0 local showingKey local sharpt,flattt=false,false - --- PREPARE VIRTUAL KEYS --- PREPARE VIRTUAL KEYS --- NOTE: I made this list because I want to use WIDGET.draw() and don't need another function --- I will handling the behavior in an other function -local virtualKeys={ - -- Number row: 01234567890-= 13 - WIDGET.newKey {name='key1' ,x= 75,y=335,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=pressKey'1' }, - WIDGET.newKey {name='key2' ,x= 165,y=335,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=pressKey'2' }, - WIDGET.newKey {name='key3' ,x= 255,y=335,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=pressKey'3' }, - WIDGET.newKey {name='key4' ,x= 345,y=335,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=pressKey'4' }, - WIDGET.newKey {name='key5' ,x= 435,y=335,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=pressKey'5' }, - WIDGET.newKey {name='key6' ,x= 525,y=335,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=pressKey'6' }, - WIDGET.newKey {name='key7' ,x= 615,y=335,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=pressKey'7' }, - WIDGET.newKey {name='key8' ,x= 755,y=335,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=pressKey'8' }, - WIDGET.newKey {name='key9' ,x= 845,y=335,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=pressKey'9' }, - WIDGET.newKey {name='key0' ,x= 935,y=335,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=pressKey'0' }, - WIDGET.newKey {name='key-' ,x=1025,y=335,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=pressKey'-' }, - WIDGET.newKey {name='key=' ,x=1115,y=335,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=pressKey'=' }, - WIDGET.newKey {name='keyBACKSPACE',x=1205,y=335,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=pressKey'backspace'}, - - -- Top row: QWERTYUIOP[]\ 13 - WIDGET.newKey {name='keyQ' ,x= 75,y=425,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=pressKey'q' }, - WIDGET.newKey {name='keyW' ,x= 165,y=425,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=pressKey'w' }, - WIDGET.newKey {name='keyE' ,x= 255,y=425,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=pressKey'e' }, - WIDGET.newKey {name='keyR' ,x= 345,y=425,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=pressKey'r' }, - WIDGET.newKey {name='keyT' ,x= 435,y=425,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=pressKey't' }, - WIDGET.newKey {name='keyY' ,x= 525,y=425,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=pressKey'y' }, - WIDGET.newKey {name='keyU' ,x= 615,y=425,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=pressKey'u' }, - WIDGET.newKey {name='keyI' ,x= 755,y=425,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=pressKey'i' }, - WIDGET.newKey {name='keyO' ,x= 845,y=425,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=pressKey'o' }, - WIDGET.newKey {name='keyP' ,x= 935,y=425,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=pressKey'p' }, - WIDGET.newKey {name='key[' ,x=1025,y=425,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=pressKey'[' }, - WIDGET.newKey {name='key]' ,x=1115,y=425,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=pressKey']' }, - WIDGET.newKey {name='key\\' ,x=1205,y=425,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=pressKey'\\'}, - - -- Home row ASDFGHJKL;'' 12 - WIDGET.newKey {name='keyA' ,x= 75,y=515,w=75 ,h=75,sound=false,font=35,fText='',color='R',code=pressKey'a' }, - WIDGET.newKey {name='keyS' ,x= 165,y=515,w=75 ,h=75,sound=false,font=35,fText='',color='W',code=pressKey's' }, - WIDGET.newKey {name='keyD' ,x= 255,y=515,w=75 ,h=75,sound=false,font=35,fText='',color='P',code=pressKey'd' }, - WIDGET.newKey {name='keyF' ,x= 345,y=515,w=75 ,h=75,sound=false,font=35,fText='',color='N',code=pressKey'f' }, - WIDGET.newKey {name='keyG' ,x= 435,y=515,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=pressKey'g' }, - WIDGET.newKey {name='keyH' ,x= 525,y=515,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=pressKey'h' }, - WIDGET.newKey {name='keyJ' ,x= 615,y=515,w=75 ,h=75,sound=false,font=35,fText='',color='O',code=pressKey'j' }, - WIDGET.newKey {name='keyK' ,x= 755,y=515,w=75 ,h=75,sound=false,font=35,fText='',color='L',code=pressKey'k' }, - WIDGET.newKey {name='keyL' ,x= 845,y=515,w=75 ,h=75,sound=false,font=35,fText='',color='G',code=pressKey'l' }, - WIDGET.newKey {name='key;' ,x= 935,y=515,w=75 ,h=75,sound=false,font=35,fText='',color='C',code=pressKey';' }, - WIDGET.newKey {name='key\'' ,x=1025,y=515,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=pressKey'\'' }, - WIDGET.newKey {name='keyRETURN' ,x=1115,y=515,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=pressKey'return'}, - - -- Bottom row ZXCVBNM,./ 10 - WIDGET.newKey {name='keyZ' ,x= 75,y=605,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=pressKey'z'}, - WIDGET.newKey {name='keyX' ,x= 165,y=605,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=pressKey'x'}, - WIDGET.newKey {name='keyC' ,x= 255,y=605,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=pressKey'c'}, - WIDGET.newKey {name='keyV' ,x= 345,y=605,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=pressKey'v'}, - WIDGET.newKey {name='keyB' ,x= 435,y=605,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=pressKey'b'}, - WIDGET.newKey {name='keyN' ,x= 525,y=605,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=pressKey'n'}, - WIDGET.newKey {name='keyM' ,x= 615,y=605,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=pressKey'm'}, - WIDGET.newKey {name='key,' ,x= 755,y=605,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=pressKey','}, - WIDGET.newKey {name='key.' ,x= 845,y=605,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=pressKey'.'}, - WIDGET.newKey {name='key/' ,x= 935,y=605,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=pressKey'/'}, - - WIDGET.newKey {name='keyCtrl' ,x=1115,y=605,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=function() flattt=not flattt;sharpt=false end}, - WIDGET.newKey {name='keyShift' ,x=1205,y=605,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=function() sharpt=not sharpt;flattt=false end}, -} -setmetatable(virtualKeys,{__index=function(L,k) for i=1,#L do if L[i].name==k then return L[i] end end end}) - --- Set objects text -virtualKeys['keyCtrl'] :setObject(CHAR.key.ctrl ) -virtualKeys['keyShift']:setObject(CHAR.key.shift) --- Overwrite some functions -for k=1,#virtualKeys do - local K=virtualKeys[k] - -- Overwrite the update function - function K:update(activateState) - -- activateState - -- 0 - Off - -- 1 - On then off - -- 2 - On - local dt=love.timer.getDelta() - local ATV=self.ATV - local maxTime=6.2 - - if activateState~=nil then self.activateState=activateState - elseif (self.activateState==1 and ATV==maxTime) or not self.activateState then self.activateState=0 end - - -- When I can emulate holding key - -- self.activateState=activateState and activateState or not ATV>maxTime and self.activateState end - - if self.activateState>0 then - self.ATV=min(ATV+dt*60,maxTime) - elseif ATV>0 then - self.ATV=max(ATV-dt*30,0) - end - end - -- Remove unnecessary function (reduce memory usage) - function K:getCenter() end - function K:getInfo() end - function K:drag() end - function K:release() end -end ---/ PREPARE VIRTUAL KEYS ---/ PREPARE VIRTUAL KEYS +local virtualKeys={} -- Virtual key set is near the end of the file. +local touchPosition={} local scene={} @@ -136,19 +36,22 @@ local function _showVirtualKey(switch) end end -local function _notHoldCS(a) +local function _notHoldCS() + tempoffset=0 + _setNoteName(offset) flattt,sharpt=false,false virtualKeys['keyCtrl'].color,virtualKeys['keyShift'].color=COLOR.Z,COLOR.Z - if not a then _setNoteName(offset) end end local function _holdingCtrl() - _notHoldCS(1) + _notHoldCS() virtualKeys['keyCtrl'].color=COLOR.R + tempoffset=-1 _setNoteName(offset-1) end local function _holdingShift() - _notHoldCS(1) + _notHoldCS() virtualKeys['keyShift'].color=COLOR.R + tempoffset=1 _setNoteName(offset+1) end @@ -163,25 +66,48 @@ function scene.enter() _showVirtualKey(MOBILE and true or false) end -function scene.touchDown(x,y,_) +function scene.mouseDown(x,y,_) + -- Behavior for mouse is different than a bit + -- Detail: Ctrl/Shift state will be reset after a note is clicked! + local lastK if showingKey then - for k=1,#virtualKeys do - local K=virtualKeys[k] - if K:isAbove(x,y) then K.code(); K:update(1) end end + for k,K in pairs(virtualKeys) do + if K:isAbove(x,y) then K.code(); K:update(1); lastK=string.sub(K.name:lower(),4) end + end + -- Check if there is a key other than Ctrl/Shift is hold + -- if yes then automatically swap Ctrl/Shift state + if keys[lastK] then _notHoldCS() end -- Change Shift/Ctrl key's color when shift note temproraily if flattt or sharpt then if flattt then _holdingCtrl() else _holdingShift() end - else _notHoldCS() end + end + end +end +function scene.multipleTouch() -- Check for every touch keys + _notHoldCS() + for _,pos in pairs(touchPosition) do + local x,y=pos[1],pos[2] + for i,currentKey in pairs(virtualKeys) do + if not (currentKey.name=="keyCtrl" or currentKey.name=="keyShift") then + if currentKey:isAbove(x,y) then currentKey:code(); currentKey:update(1) end + end + end + if virtualKeys.keyCtrl :isAbove(x,y) then _holdingCtrl() + elseif virtualKeys.keyShift:isAbove(x,y) then _holdingShift() end end end -scene.mouseDown=scene.touchDown -scene.mouseUp =scene.touchUp +function scene.touchDown(x,y) + table.insert(touchPosition,{x,y}) + scene.multipleTouch() +end +function scene.touchUp(x,y) + table.remove(touchPosition,TABLE.find(touchPosition,{x,y})) + scene.multipleTouch() +end function scene.keyDown(key,isRep) if not isRep and keys[key] then - local note=keys[key]+offset - if kb.isDown('lshift','rshift') or sharpt then note=note+1 end - if kb.isDown('lctrl','rctrl') or flattt then note=note-1 end + local note=keys[key]+offset+tempoffset SFX.playSample(inst,note) if showingKey then virtualKeys['key'..key:upper()]:update(1) @@ -189,8 +115,8 @@ function scene.keyDown(key,isRep) else TEXT.show(SFX.getNoteName(note),math.random(75,1205),math.random(162,620),60,'score',.8) end - elseif kb.isDown('lctrl','rctrl') then _holdingCtrl() - elseif kb.isDown('lshift','rshift') then _holdingShift() + elseif kb.isDown('lctrl','rctrl') and not isRep then _holdingCtrl() + elseif kb.isDown('lshift','rshift') and not isRep then _holdingShift() elseif key=='tab' then inst=TABLE.next(instList,inst) elseif key=='lalt' then @@ -217,8 +143,8 @@ function scene.draw() -- Drawing virtual keys if showingKey then - for k=1,#virtualKeys do - virtualKeys[k]:draw() + for i,currentKey in pairs(virtualKeys) do + currentKey:draw() end gc.setLineWidth(1) gc.setColor(COLOR.Z) @@ -227,8 +153,9 @@ function scene.draw() end function scene.update() - -- Call actions - for k=1,#virtualKeys do virtualKeys[k]:update() end + for i,currentKey in pairs(virtualKeys) do + currentKey:update() + end end scene.widgetList={ @@ -238,4 +165,102 @@ scene.widgetList={ WIDGET.newKey {name='offset-' ,x=485 ,y=60,w=60 ,h=60,fText=CHAR.key.left ,code=pressKey"lalt",hideF=function() return not showingKey end}, WIDGET.newKey {name='offset+' ,x=555 ,y=60,w=60 ,h=60,fText=CHAR.key.right ,code=pressKey"ralt",hideF=function() return not showingKey end}, } + +-- Set virtual keys (seperate from ZFramework) +virtualKeys={ + -- Number row: 01234567890-= 13 + WIDGET.newKey {name='key1' ,x= 75,y=335,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=function() scene.keyDown('1' ) end}, + WIDGET.newKey {name='key2' ,x= 165,y=335,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=function() scene.keyDown('2' ) end}, + WIDGET.newKey {name='key3' ,x= 255,y=335,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=function() scene.keyDown('3' ) end}, + WIDGET.newKey {name='key4' ,x= 345,y=335,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=function() scene.keyDown('4' ) end}, + WIDGET.newKey {name='key5' ,x= 435,y=335,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=function() scene.keyDown('5' ) end}, + WIDGET.newKey {name='key6' ,x= 525,y=335,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=function() scene.keyDown('6' ) end}, + WIDGET.newKey {name='key7' ,x= 615,y=335,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=function() scene.keyDown('7' ) end}, + WIDGET.newKey {name='key8' ,x= 755,y=335,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=function() scene.keyDown('8' ) end}, + WIDGET.newKey {name='key9' ,x= 845,y=335,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=function() scene.keyDown('9' ) end}, + WIDGET.newKey {name='key0' ,x= 935,y=335,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=function() scene.keyDown('0' ) end}, + WIDGET.newKey {name='key-' ,x=1025,y=335,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=function() scene.keyDown('-' ) end}, + WIDGET.newKey {name='key=' ,x=1115,y=335,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=function() scene.keyDown('=' ) end}, + WIDGET.newKey {name='keyBACKSPACE',x=1205,y=335,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=function() scene.keyDown('backspace') end}, + + -- Top row: QWERTYUIOP[]\ 13 + WIDGET.newKey {name='keyQ' ,x= 75,y=425,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=function() scene.keyDown('q' ) end}, + WIDGET.newKey {name='keyW' ,x= 165,y=425,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=function() scene.keyDown('w' ) end}, + WIDGET.newKey {name='keyE' ,x= 255,y=425,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=function() scene.keyDown('e' ) end}, + WIDGET.newKey {name='keyR' ,x= 345,y=425,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=function() scene.keyDown('r' ) end}, + WIDGET.newKey {name='keyT' ,x= 435,y=425,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=function() scene.keyDown('t' ) end}, + WIDGET.newKey {name='keyY' ,x= 525,y=425,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=function() scene.keyDown('y' ) end}, + WIDGET.newKey {name='keyU' ,x= 615,y=425,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=function() scene.keyDown('u' ) end}, + WIDGET.newKey {name='keyI' ,x= 755,y=425,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=function() scene.keyDown('i' ) end}, + WIDGET.newKey {name='keyO' ,x= 845,y=425,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=function() scene.keyDown('o' ) end}, + WIDGET.newKey {name='keyP' ,x= 935,y=425,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=function() scene.keyDown('p' ) end}, + WIDGET.newKey {name='key[' ,x=1025,y=425,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=function() scene.keyDown('[' ) end}, + WIDGET.newKey {name='key]' ,x=1115,y=425,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=function() scene.keyDown(']' ) end}, + WIDGET.newKey {name='key\\' ,x=1205,y=425,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=function() scene.keyDown('\\') end}, + + -- Home row ASDFGHJKL;'' 12 + WIDGET.newKey {name='keyA' ,x= 75,y=515,w=75 ,h=75,sound=false,font=35,fText='',color='R',code=function() scene.keyDown('a' ) end}, + WIDGET.newKey {name='keyS' ,x= 165,y=515,w=75 ,h=75,sound=false,font=35,fText='',color='W',code=function() scene.keyDown('s' ) end}, + WIDGET.newKey {name='keyD' ,x= 255,y=515,w=75 ,h=75,sound=false,font=35,fText='',color='P',code=function() scene.keyDown('d' ) end}, + WIDGET.newKey {name='keyF' ,x= 345,y=515,w=75 ,h=75,sound=false,font=35,fText='',color='N',code=function() scene.keyDown('f' ) end}, + WIDGET.newKey {name='keyG' ,x= 435,y=515,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=function() scene.keyDown('g' ) end}, + WIDGET.newKey {name='keyH' ,x= 525,y=515,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=function() scene.keyDown('h' ) end}, + WIDGET.newKey {name='keyJ' ,x= 615,y=515,w=75 ,h=75,sound=false,font=35,fText='',color='O',code=function() scene.keyDown('j' ) end}, + WIDGET.newKey {name='keyK' ,x= 755,y=515,w=75 ,h=75,sound=false,font=35,fText='',color='L',code=function() scene.keyDown('k' ) end}, + WIDGET.newKey {name='keyL' ,x= 845,y=515,w=75 ,h=75,sound=false,font=35,fText='',color='G',code=function() scene.keyDown('l' ) end}, + WIDGET.newKey {name='key;' ,x= 935,y=515,w=75 ,h=75,sound=false,font=35,fText='',color='C',code=function() scene.keyDown(';' ) end}, + WIDGET.newKey {name='key\'' ,x=1025,y=515,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=function() scene.keyDown('\'' ) end}, + WIDGET.newKey {name='keyRETURN' ,x=1115,y=515,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=function() scene.keyDown('return') end}, + + -- Bottom row ZXCVBNM,./ 10 + WIDGET.newKey {name='keyZ' ,x= 75,y=605,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=function() scene.keyDown('z') end}, + WIDGET.newKey {name='keyX' ,x= 165,y=605,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=function() scene.keyDown('x') end}, + WIDGET.newKey {name='keyC' ,x= 255,y=605,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=function() scene.keyDown('c') end}, + WIDGET.newKey {name='keyV' ,x= 345,y=605,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=function() scene.keyDown('v') end}, + WIDGET.newKey {name='keyB' ,x= 435,y=605,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=function() scene.keyDown('b') end}, + WIDGET.newKey {name='keyN' ,x= 525,y=605,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=function() scene.keyDown('n') end}, + WIDGET.newKey {name='keyM' ,x= 615,y=605,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=function() scene.keyDown('m') end}, + WIDGET.newKey {name='key,' ,x= 755,y=605,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=function() scene.keyDown(',') end}, + WIDGET.newKey {name='key.' ,x= 845,y=605,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=function() scene.keyDown('.') end}, + WIDGET.newKey {name='key/' ,x= 935,y=605,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=function() scene.keyDown('/') end}, + + WIDGET.newKey {name='keyCtrl' ,x=1115,y=605,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=function() if not flattt then _holdingCtrl() else _notHoldCS() end end}, + WIDGET.newKey {name='keyShift' ,x=1205,y=605,w=75 ,h=75,sound=false,font=35,fText='',color='Z',code=function() if not sharpt then _holdingShift() else _notHoldCS() end end}, +} +setmetatable(virtualKeys,{__index=function(L,k) for i=1,#L do if L[i].name==k then return L[i] end end end}) + +-- Set objects text +virtualKeys['keyCtrl'] :setObject(CHAR.key.ctrl ) +virtualKeys['keyShift']:setObject(CHAR.key.shift) +-- Overwrite some functions +for k=1,#virtualKeys do + local K=virtualKeys[k] + -- Overwrite the update function + function K:update(activateState) + -- activateState + -- 0 - Off + -- 1 - On then off + -- 2 - On + local dt=love.timer.getDelta() + local ATV=self.ATV + local maxTime=6.2 + + if activateState~=nil then self.activateState=activateState + elseif (self.activateState==1 and ATV==maxTime) or not self.activateState then self.activateState=0 end + + -- When I can emulate holding key + -- self.activateState=activateState and activateState or not ATV>maxTime and self.activateState end + + if self.activateState>0 then + self.ATV=min(ATV+dt*60,maxTime) + elseif ATV>0 then + self.ATV=max(ATV-dt*30,0) + end + end + -- Remove unnecessary function (reduce memory usage) + function K:getCenter() end + function K:getInfo() end + function K:drag() end + function K:release() end +end return scene