Hi
Thanks Jonathan and his tutorials I’am trying to improve my coding skills…
All my ui buttons or particles in one file is great thing.
so what I am trying to do :
---- buttons.lua
local button = {}
local ui = require("ui")
function newButton(xPos, yPos)
local doSomething = function(event)
if event.phase == "release" then
print("do do do")
end
end
local playB = ui.newButton{
defaultSrc = "playButton.png",
defaultX = 150,
defaultY = 52,
overSrc = "playButton.png",
overX = 160,
overY = 62,
onEvent = doSomething,
id = "PlayButton",
text = "",
font = "Helvetica",
textColor = { 255, 255, 255, 255 },
size = 16,
emboss = false
}
playB.x = xPos
playB.y = yPos
end
button.newButton = newButton
return button
and then in my levels
local buttons = require("buttons")
local pauseButton = buttons.newButton(100,100)
but why I can not add this to displayGroup ?
[import]uid: 13156 topic_id: 16326 reply_id: 316326[/import]
[import]uid: 3826 topic_id: 16326 reply_id: 60810[/import]