asd
This commit is contained in:
parent
59d71e3c27
commit
9690d82140
@ -90,12 +90,14 @@ And in main.lua:
|
|||||||
|
|
||||||
Now theres a lot to explain, but its fairly simple, so lets take it by chunks
|
Now theres a lot to explain, but its fairly simple, so lets take it by chunks
|
||||||
```lua
|
```lua
|
||||||
|
|
||||||
local input = require "helium.core.input"
|
local input = require "helium.core.input"
|
||||||
```
|
```
|
||||||
Here we import the input module of Helium, so that we can later subscribe to an event
|
Here we import the input module of Helium, so that we can later subscribe to an event
|
||||||
|
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
|
|
||||||
state.pressed = false
|
state.pressed = false
|
||||||
```
|
```
|
||||||
Here we create a state field called pressed, think of state as a helium elements self
|
Here we create a state field called pressed, think of state as a helium elements self
|
||||||
@ -103,18 +105,21 @@ It works like a regular table, with the caveat that you shouldnt overwrite it di
|
|||||||
|
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
|
|
||||||
local callback = function() state.pressed = true end
|
local callback = function() state.pressed = true end
|
||||||
```
|
```
|
||||||
Then we overwrite that state.pressed inside a callback which will be called every time our button is pressed
|
Then we overwrite that state.pressed inside a callback which will be called every time our button is pressed
|
||||||
|
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
|
|
||||||
input.subscribe(0,0,view.w,view.h,'clicked',callback)
|
input.subscribe(0,0,view.w,view.h,'clicked',callback)
|
||||||
```
|
```
|
||||||
This is creating an input subscription for the event of your choice
|
This is creating an input subscription for the event of your choice
|
||||||
|
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
|
|
||||||
return function()
|
return function()
|
||||||
if state.pressed then
|
if state.pressed then
|
||||||
love.graphics.setColor(0.3,0.3,0.9)
|
love.graphics.setColor(0.3,0.3,0.9)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user