Skip to content
JJSax edited this page Apr 22, 2021 · 3 revisions

Welcome to the jjui-love2d wiki!

My goal for this library collection was to make things simple to use, but offer great flexibility with how it functions.

Check out my other wiki pages to learn more about the individual modules. This page is mostly going to work with the general use.

Example generalized calling

First directly require the folder that init.lua is in.

ui = require("ui") -- init.lua found withing the folder called "ui"

Inside init.lua groups all the constructors in all these libraries under one variable. Example constructors

rectangle = ui.newRectangleButton( 50, 50, 150, 100 )
circle = ui.newCircleButton( 100, 50, 25 )
dial = ui.newDial( 200, 50, 50 )
ui.newArcButton( dial, 0, math.pi/2 )

Example Sets

function love.load()
    mainMenu = ui.newSet()
    pauseMenu = ui.newSet()
    rectangleButton1 = ui.newRectangleButton(1, 1, 50, 50)
    rectangleButton2 = ui.newRectangleButton(1, 1, 50, 50)
    rectangleButton3 = ui.newRectangleButton(1, 1, 50, 50)
    mainMenu:add(rectangleButton1, rectangleButton2, rectangleButton3)
    pauseMenu:add(rectangleButton1) -- buttons can be added to multiple menus, if they are needed in multiple sets.
end

function love.update(dt)
    mainMenu:update(dt) -- notice you don't have to call update on all the buttons individually
    pauseMenu:update(dt)
end

function love.draw()
    mainMenu:draw()
    pauseMenu:draw()
end
Clone this wiki locally