edited the readme some more

This commit is contained in:
Josh
2018-06-14 12:32:10 -05:00
parent 156d378668
commit 56f7ce79a9
3 changed files with 29 additions and 6 deletions

View File

@@ -35,5 +35,7 @@ return {
unparent = function(self, parent, child)
parent:removeChild(child.name)
child:setParent(nil)
end
end,
version = "0.1pre",
}

View File

@@ -1,6 +1,16 @@
# JUI Library
A library that adds simple GUI elements for you to utilize in your Love2D games.
## Features
* Lightweight and object-oriented GUI elements
* Helpful objects such as sliders and buttons
* FOSS, designed to be easily extended to fit your game's needs
* Automatic element scaling
The full API docs can be found in the API.md file.
## Basic Setup
Download the library and place the JUI folder in your project, the library can be required with:
@@ -13,7 +23,10 @@ local JUI = require("JUI/JUIlib") -- I recommend calling the required variable "
To set up a basic UI scene, a JUIScene is created and objects to be rendered are parented to it. The JUIScene must be rendered and updated inside the appropriate Love2D functions.
The full API docs can be found in the API.md file.
Object size and position is controlled through the Dimension datatype.
The first two arguments are numbers representing the percentage of the parent's size, or the Dimension's scale.
For example, setting an object's Size to `Dimension:new(0.5, 0.5)` will make it 50% the size of it's parent.
The third and fourth arguments are pixel sizes, which are added to the size afterwards.
```lua
-- creates a UIContainer and a Frame object, and renders them.
@@ -21,11 +34,13 @@ local scene = JUI.JUIScene:new()
local frame = JUI.Frame:new()
frame:setName("BackgroundFrame")
frame:setBackgroundColor(JUI.Color:new(1, 0.5, 0.5))
frame:setBackgroundColor(JUI.Color:new(1, 0.5, 0.5)) -- transparency is an optional fourth argument
frame:setSize(JUI.Dimension:new(0.3, 0.3, 64, 64)) -- 30% the parent's size, plus 64 pixels on each axis
-- JUI objects also may have events you can connect your own functions to listen to.
-- connect a new event listener
frame.mouseEnter:connect(function()
print("Mouse inside!")
end)
JUI:parent(scene, frame) -- the current method of setting the parent of an object
@@ -44,5 +59,9 @@ end
## Other Information
### Help
If you have any issues or questions about JUI, feel free to contact me on Discord: **Josh Mad Scientist#6360**
### Credits:
This project utilizes the YACI library. https://github.com/jpatte/yaci.lua

View File

@@ -2,6 +2,8 @@
This is an example project, demonstrating how to use JUI,
and what can be done with it.
You should probably remove this when you drop JUI into your project.
]]--
local JUI = require("JUIlib")
@@ -9,12 +11,12 @@ local JUI = require("JUIlib")
local mainmenu = JUI.JUIScene:new()
local testSlider = JUI.Slider:new()
local testSlider = JUI.Slider:new() do -- just formatting
testSlider:setPosition(JUI.Dimension:new(0.3, 0.2))
testSlider:setSize(JUI.Dimension:new(0.4, 0.1))
testSlider:setValueRange(2, 32)
testSlider:setValueIncrement(2)
end
JUI:parent(mainmenu, testSlider)