Hey everybody! I'm new to Pico-8 dev, so for a quick project to learn the ropes I threw together a class that lets you program your button-based logic with an event handler, rather than by polling. It probably sucks because it could potentially do a lot of polling, and I used a closure instead of setmetadata to implement the OO (I'm new to both Pico-8 and Lua) but I figured I'd throw it up here in case it could benefit someone.
Here are the features:
- Notifies on button pressed, passing the button number and player number
- Notifies on button released, passing the button number, player number, and total frames the button was pressed
- Can retrieve the current number of frames a button has been pressed at any time
- Number of players can be specified on instantiation, so that only buttons for valid players are polled
[Please log in to post a comment]