Log In  
Follow
jamma
[ :: Read More :: ]

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

Cart #37321 | 2017-02-10 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
2

P#37322 2017-02-09 23:39 ( Edited 2017-02-10 04:47)

Follow Lexaloffle:          
Generated 2024-04-19 07:14:29 | 0.082s | Q:8