mirror of
https://github.com/keharriso/love-nuklear.git
synced 2025-09-10 16:17:47 -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:
|
||||
```lua
|
||||
local nk = require 'nuklear'
|
||||
local nuklear = require 'nuklear'
|
||||
|
||||
local ui
|
||||
|
||||
function love.load()
|
||||
love.keyboard.setKeyRepeat(true)
|
||||
nk.init()
|
||||
ui = nuklear.init()
|
||||
end
|
||||
|
||||
function love.update(dt)
|
||||
nk.frameBegin()
|
||||
ui:frameBegin()
|
||||
-- Add UI code here
|
||||
nk.frameEnd()
|
||||
ui:frameEnd()
|
||||
end
|
||||
|
||||
function love.draw()
|
||||
nk.draw()
|
||||
ui:draw()
|
||||
end
|
||||
|
||||
function love.keypressed(key, scancode, isrepeat)
|
||||
if nk.keypressed(key, scancode, isrepeat) then
|
||||
if ui:keypressed(key, scancode, isrepeat) then
|
||||
return -- event consumed
|
||||
end
|
||||
end
|
||||
|
||||
function love.keyreleased(key, scancode)
|
||||
if nk.keyreleased(key, scancode) then
|
||||
if ui:keyreleased(key, scancode) then
|
||||
return -- event consumed
|
||||
end
|
||||
end
|
||||
|
||||
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
|
||||
end
|
||||
end
|
||||
|
||||
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
|
||||
end
|
||||
end
|
||||
|
||||
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
|
||||
end
|
||||
end
|
||||
|
||||
function love.textinput(text)
|
||||
if nk.textinput(text) then
|
||||
if ui:textinput(text) then
|
||||
return -- event consumed
|
||||
end
|
||||
end
|
||||
|
||||
function love.wheelmoved(x, y)
|
||||
if nk.wheelmoved(x, y) then
|
||||
if ui:wheelmoved(x, y) then
|
||||
return -- event consumed
|
||||
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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue