I am facing an issue using button A to move on different pages/frames. I aim to use button A to continue to the next page (multiple pages).
Here is the code:
function playdate.update()
if playdate.buttonIsPressed(playdate.kButtonA) then
welcomeText()
end
if playdate.buttonIsPressed(playdate.kButtonA) then
gameInfo()
end
end
You want each press of A to advance to the next page, and so far your two pages are welcomeText and gameInfo, right?
I think you're misunderstanding how playdate.update() works.
Think of this function as the body of a loop that runs once per frame. What you want to do is check whether a button has been pressed since the last loop (not whether it's currently pressed) and if so, advance to the next page, then draw everything for whatever page we're on. You don't want to check for another page-turn until the next time update() is called.
Something like:
local currentPage = 1
function playdate.update()
-- note: buttonJustPressed, not buttonIsPressed
if playdate.buttonJustPressed(playdate.kButtonA) then
currentPage += 1
end
if currentPage == 1 then
drawWelcomePage()
elseif currentPage == 2 then
drawGameInfoPage()
elseif currentPage == 3 then
-- ... and so on for the rest of the pages
end
end