Probably everyone has one of these... sharing in case you don't and need a quick wrapper around the mouse support.
The library implements an OOP like MOUSE object that supports 2 buttons and provides the following methods:
- enable() : Enables mouse suport
- disable() : Disables mouse support
- pressed(<num>) : true/false if button number <num> is pressed in current frame
- clicked(<num>) : true/false if button number <num> is pressed in current frame but was not in the previous
- released(<num>) : true/false if button number <num> is not pressed but was in the previous frame
- inside(minx,miny,maxx,maxy) : true/false if mouse is inside the defined rect boundaries
Would be quite easy to extend, mouse cursor can be set to any spritesheet index and would be easy to handle animated cursors, bigger cursors and such...
The demo cart shows how it behaves... pressing buttons changes background color, clicking and releasing draw some points on the screen (in green hues for btn 1, blue hues for btn 2.. brighter for click, darker for release)
[Please log in to post a comment]