Howdy, I'm totally new at Gideros and I've recently picked up the 2013 Packt book, Gideros Mobile Game Dev. However, straight out the gate in chapter 2 (bottom of page 44) I'm receiving an error when it is indicated that this code would correct the intentional problem (from the page before). It is frustrating to not make progress on something so rudimentary. I feel that I've checked it many times without any indication that it has been mistyped. The image, ball.png IS in the 'images' folder. So, my question would be, could it have been possible since the publishing of the book, the current base code is no longer compatible OR is there simply an error in the book. Thank you for any help!
main.lua
local bitmap = Bitmap.new(Texture.new("images/ball.png", true))
local button = Button.new(bitmap)
stage:addChild(button)
button.lua
Button = Core.class(Sprite)
function Button:init(sprite)
print("initializing button")
self.addChild(sprite)
end
The error I'm getting is:
classes/Button.lua:5: bad argument #2 to 'addChild' (Sprite expected, got no value)
stack traceback:
classes/Button.lua:5: in function 'init'
[string "property.lua"]:52: in function '__new'
[string "property.lua"]:59: in function 'new'
main.lua:3: in main chunk
Comments
A function can be defined as a property, but that is not the case