Rocket-Bytes/Source/Musicbox.lua

24 lines
696 B
Lua
Raw Normal View History

2022-06-20 05:56:43 +00:00
local paused = false
local playbackRate = 1.0
function updateBox()
local change, aChange = playdate.getCrankChange()
if paused then
2022-06-27 06:21:44 +00:00
if change<0 then change = 0 end
2022-06-20 05:56:43 +00:00
song:setRate(change*0.03)
else
playbackRate += change*0.001
2022-06-27 06:21:44 +00:00
if playbackRate < 0.2 then playbackRate = 0.2 end
2022-06-20 05:56:43 +00:00
song:setRate(playbackRate)
end
if playdate.buttonJustPressed(playdate.kButtonA) then
if paused == true then paused = false else paused = true end
playbackRate = 1.0
end
if playdate.buttonJustPressed(playdate.kButtonB) or playdate.buttonJustPressed(playdate.kButtonLeft) then
createMenu(songlist)
song:stop()
end
end