Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Luminess committed Dec 14, 2015
2 parents 709145f + 1567f3a commit 95c67fe
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,28 @@ end, true)
controls.state('game').binding('pause'):bind('q')
controls.state('game').binding('pause'):unbind({'q', 'escape'})
```
You can also bind the next key pressed to a binding like so:
```lua
-- Load the library.
local controls = require('EZControls')

-- Set the controls library state.
controls.currentState = 'game'

-- Binds the next key pressed to the binding "jetpack_fire".
controls.state('game').binding('jetpack_fire'):bindNext(function(key)
print('binded ' .. key .. ' to binding "jetpack_fire"')
end)

-- Create callbacks for the bindings.
controls.state('game').binding('jetpack_fire'):onPress(function()
enableJetpack()
end)

controls.state('game').binding('jetpack_fire'):onRelease(function()
disableJetpack()
end)
```
EZControls will check if love.keypressed, love.keyreleased, love.mousepressed, love.mousereleased, or love.mousemoved is already being used. If it isn't, it'll override them. If it is, it'll provide functions to fire control events to.
```lua
-- Override the love.keypressed function
Expand Down

0 comments on commit 95c67fe

Please sign in to comment.