mirror of
https://github.com/keharriso/love-nuklear.git
synced 2025-09-11 00:27:48 -04:00
Update for v2.0
parent
21f7bfce89
commit
a9067246ca
1 changed files with 15 additions and 13 deletions
28
Home.md
28
Home.md
|
@ -17,67 +17,69 @@ $ git clone --recursive git@github.com:keharriso/love-nuklear.git
|
||||||
|
|
||||||
The following program shows the basic code to set up and use the library, including initialization and event handling:
|
The following program shows the basic code to set up and use the library, including initialization and event handling:
|
||||||
```lua
|
```lua
|
||||||
local nk = require 'nuklear'
|
local nuklear = require 'nuklear'
|
||||||
|
|
||||||
|
local ui
|
||||||
|
|
||||||
function love.load()
|
function love.load()
|
||||||
love.keyboard.setKeyRepeat(true)
|
love.keyboard.setKeyRepeat(true)
|
||||||
nk.init()
|
ui = nuklear.init()
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.update(dt)
|
function love.update(dt)
|
||||||
nk.frameBegin()
|
ui:frameBegin()
|
||||||
-- Add UI code here
|
-- Add UI code here
|
||||||
nk.frameEnd()
|
ui:frameEnd()
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.draw()
|
function love.draw()
|
||||||
nk.draw()
|
ui:draw()
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.keypressed(key, scancode, isrepeat)
|
function love.keypressed(key, scancode, isrepeat)
|
||||||
if nk.keypressed(key, scancode, isrepeat) then
|
if ui:keypressed(key, scancode, isrepeat) then
|
||||||
return -- event consumed
|
return -- event consumed
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.keyreleased(key, scancode)
|
function love.keyreleased(key, scancode)
|
||||||
if nk.keyreleased(key, scancode) then
|
if ui:keyreleased(key, scancode) then
|
||||||
return -- event consumed
|
return -- event consumed
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.mousepressed(x, y, button, istouch)
|
function love.mousepressed(x, y, button, istouch)
|
||||||
if nk.mousepressed(x, y, button, istouch) then
|
if ui:mousepressed(x, y, button, istouch) then
|
||||||
return -- event consumed
|
return -- event consumed
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.mousereleased(x, y, button, istouch)
|
function love.mousereleased(x, y, button, istouch)
|
||||||
if nk.mousereleased(x, y, button, istouch) then
|
if ui:mousereleased(x, y, button, istouch) then
|
||||||
return -- event consumed
|
return -- event consumed
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.mousemoved(x, y, dx, dy, istouch)
|
function love.mousemoved(x, y, dx, dy, istouch)
|
||||||
if nk.mousemoved(x, y, dx, dy, istouch) then
|
if ui:mousemoved(x, y, dx, dy, istouch) then
|
||||||
return -- event consumed
|
return -- event consumed
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.textinput(text)
|
function love.textinput(text)
|
||||||
if nk.textinput(text) then
|
if ui:textinput(text) then
|
||||||
return -- event consumed
|
return -- event consumed
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.wheelmoved(x, y)
|
function love.wheelmoved(x, y)
|
||||||
if nk.wheelmoved(x, y) then
|
if ui:wheelmoved(x, y) then
|
||||||
return -- event consumed
|
return -- event consumed
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
Put your UI code between the `nk.frameBegin` and `nk.frameEnd` calls. See the bundled [example](https://github.com/keharriso/love-nuklear/tree/master/example) for a brief sample of what the library can do.
|
Put your UI code between the `ui:frameBegin` and `ui:frameEnd` calls. See the bundled [example](https://github.com/keharriso/love-nuklear/tree/master/example) for a brief sample of what the library can do.
|
||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue