Hello,
I was following Gideros mobile app development bu arturs sosins. The code in it use Button.new(text), I am trying to do exactly similar thing but it gives an error, attempt to index global Button(a nil value)
local startButton = Button.new(startText)
startButton:setPosition(conf.dx - conf.width/3, conf.dy - conf.height/4 )
self:addChild(startButton)
startButton:addEventListener("click", function()
print("Started")
end)
Please help me fix this
Comments
you need to include the Button class:
https://github.com/gideros/Button
Try:
local startText = TextField.new(conf.fontLarge, "Start Game") startText:setTextColor(0xffff00) local startButton = Button.new(startText) startButton:setPosition(conf.width/2, conf.height - 80)
self:addChild(startButton)
there you create your own Button class which accepts only text, yes