In my game I'm having an issue where buttonJustPressed and buttonJustReleased registers 3 times when first pressed.
To keep things simple I've created this stripped down code to show the problem. You can see in this gif that the gameState variable jumps from 1 to 4, but every press of the button after that just adds 1.
It this just a bug with the Simulator, or am I doing something wrong?
import "CoreLibs/graphics"
gfx = playdate.graphics
gameState = 1
function buttonCheck()
if playdate.buttonJustPressed("a") then
gameState = gameState + 1
gfx.setColor(gfx.kColorWhite)
gfx.fillRect(0,0,400,240)
end
end
function playdate.update()
if gameState == 1 then
gfx.drawTextAligned("THIS IS GAME STATE " ..gameState , 200, 100, kTextAlignment.center)
buttonCheck()
end
if gameState == 2 then
gfx.drawTextAligned("THIS IS GAME STATE " ..gameState , 200, 100, kTextAlignment.center)
buttonCheck()
end
if gameState >= 3 then
gfx.drawTextAligned("THIS IS GAME STATE " ..gameState , 200, 100, kTextAlignment.center)
buttonCheck()
end
end