Log In  

Cart #22727 | 2016-06-12 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA

UPDATE: (0.2) Updated the mouse library so that the cursor can be driven by the gamepad OR the mouse at any time, to make the cart compatible with all Pico-8 devices.

I'm cobbling together a UI/mouse library for my own use, and thought it might be useful to others. For now the only widget is a button, but I wrote the API so that it's easy to modify and extend (in theory). Will provide more documentation if there's interest.

This would be a quick "hello world" with the library, for instance:

--button "onclick" callback
function hideme(this)

function _init()
 --enable the mouse and
 --set the cursor to a 6x6 sprite 
 --at index 0

 --create a new parent UI and
 --make it the active one
 mainui = ui_make()

 --make a button labeled "hello, world!" 
 --which calls hideme() when clicked.
 --It will draw at screen position (30,30).
 --I could also optionally specify a width and height,
 --but if I leave it out the button will be sized automatically
 --based on the length of the label text.
 btn_make(mainui, "hello, world!", hideme, 30, 30)

function _update()
 --update mouse position and do event callbacks
 --as needed

function _draw()

 --print mouse position
 print(mouse.x.." "..mouse.y,0,0,7)

 -- draw mouse on top of UI

thanks to gamax92 for uncovering this nifty feature...

P#22582 2016-06-10 02:25 ( Edited 2016-06-12 07:00)

Why not QWERTY? :)

P#22585 2016-06-10 03:57 ( Edited 2016-06-10 07:57)

Solidarity with AZERTY-users? (Also I didn't want to encourage anyone to actually use this as a keyboard...)

P#22590 2016-06-10 04:12 ( Edited 2016-06-10 08:33)

(Also I didn't want to encourage anyone to actually use this as a keyboard...)

Why not Dvorak then?

P#22595 2016-06-10 06:44 ( Edited 2016-06-10 10:45)

Bépo !!! (french dvorak) lol
hiragana? katakana?
More seriously, I'm trying to do a small katakana font to be used with the code of my cartridge about font.

P#22598 2016-06-10 06:58 ( Edited 2016-06-10 10:58)

This will help me :-)

P#22688 2016-06-11 15:27 ( Edited 2016-06-11 19:27)

[Please log in to post a comment]