jamma [Lexaloffle Blog Feed]https://www.lexaloffle.com/bbs/?uid=21501 Button Event Dispatcher <p>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. </p> <p>Here are the features:</p> <ul> <li>Notifies on button pressed, passing the button number and player number</li> <li>Notifies on button released, passing the button number, player number, and total frames the button was pressed</li> <li>Can retrieve the current number of frames a button has been pressed at any time</li> <li>Number of players can be specified on instantiation, so that only buttons for valid players are polled</li> </ul> <p> <table><tr><td> <a href="/bbs/?pid=37322#p"> <img src="/bbs/thumbs/pico37321.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=37322#p"> Button Event Dispatcher</a><br><br> by <a href="/bbs/?uid=21501"> jamma</a> <br><br><br> <a href="/bbs/?pid=37322#p"> [Click to Play]</a> </td></tr></table> </p> https://www.lexaloffle.com/bbs/?tid=28810 https://www.lexaloffle.com/bbs/?tid=28810 Thu, 09 Feb 2017 23:39:49 UTC