Skip to content

Commit

Permalink
piano小程序添加synthNote功能预设
Browse files Browse the repository at this point in the history
  • Loading branch information
MrZ626 committed Nov 20, 2024
1 parent b450ff6 commit 2c5c6e9
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions assets/scene_app/piano.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,40 @@ local inst,offset,release
local instList={'organ_wave','square_wave','saw_wave','complex_wave','stairs_wave','spectral_wave'}
local presets={}

local scrollSpeed=620
local disappearDist=-800
presets.synthNote={}
---@return Techmino.Piano.Object
function presets.synthNote.newNote()
return {
len=0,
free=false,
_type='synthNote',
_update=function(self,dt)
local dSize=dt*scrollSpeed
self.y=self.y-dSize
if self.free then
return self.y+self.len<disappearDist
else
self.len=self.len+dSize
end
end,
_draw=function(self)
gc_setColor(self.color)
gc_rect('fill',self.x,self.y,self.w,self.len,10)
end,
}
end
function presets.synthNote.press(key)
key.note=presets.synthNote.newNote()
TABLE.update(key.note,{x=key.x,y=key.y,w=key.w,color=key.fillC})
ins(objPool,key.note)
end
function presets.synthNote.release(key)
key.note.free=true
key.note=nil
end

---@class Techmino.Piano.Object
---@field _type string
---@field _update fun(dt:number):any
Expand Down

0 comments on commit 2c5c6e9

Please sign in to comment.