Samuel Bili
New Member
- Joined
- Oct 3, 2021
- Messages
- 8
- Reaction score
- 0
I created a button, but when I call the function
, it returns a nil value.
teste.lua
teste.otui
Lua:
mymodule:recursiveGetChildById('test')
teste.lua
Lua:
function init()
mainWindow = nil
mainButton = nil
mainWindow = g_ui.displayUI('teste.otui')
mainWindow:hide()
connect(g_game, { onGameStart = show,
onGameEnd = hide })
end
function terminate()
g_keyboard.unbindKeyDown('Shift+F12')
mainWindow:hide()
disconnect(g_game, { onGameStart = show,
onGameEnd = hide })
end
function hide()
mainWindow:hide()
end
function show()
mainWindow:show()
end
function image()
button = mymodule:recursiveGetChildById('test')
b.setImageSource('/images/test2')
end
teste.otui
CSS:
UIButton
id: test
anchors.left: parent.left
anchors.top: parent.top
margin-top: 50
margin-left: 50
width: 78
height: 71
image-source: /images/test
@onClick: print('test')
@isPressed: modules.game_teste.image()