Code is simple, but getting a message of attempt to index global 'assets' (a nil value) on the dots line. There must be somthing blaringly obvious here, but I cant see it. any ideas?
local dots = { assets:init("./images/1.png")}
function assets:init(texture)
local bitmap = Bitmap.new(Texture.new(texture))
self:addChild(bitmap)
end
REAL programmers type copy con filename.exe
---------------------------------------
Comments
1. What is assets? you need to have that instantiated before you use it. So adding a line like
2. You need to position the line
3. Since you are using
Author of Learn Lua for iOS Game Development from Apress ( http://www.apress.com/9781430246626 )
Cool Vizify Profile at https://www.vizify.com/oz-apps
---------------------------------------
I have used "/" not "./" as I think this is more correct. Gideros will automatically load your file from the Resources directory. The "." directory is really only meaningful when using a command prompt/Xterm window.
Likes: Cyberience
https://github.com/gideros/gideros
https://www.youtube.com/c/JohnBlackburn1975
---------------------------------------
assets = Core.class(Sprite)
function assets:init(texture)
local bitmap = Bitmap.new(Texture.new(texture))
bitmap:setAnchorPoint(0.5, 0.5)
self:addChild(bitmap)
end
dots = { assets.new("./images/1.png"),
assets.new("./images/2.png"),
assets.new("./images/3.png"),
assets.new("./images/4.png"),
assets.new("./images/5.png") }
local function onTouchesBegin(event)
local dot = dots[event.touch.id]
if dot then
stage:addChild(dot)
dot:setPosition(event.touch.x, event.touch.y)
end
end
stage:addEventListener(Event.TOUCHES_BEGIN, onTouchesBegin)
Theres more, like on move and touch end, but the above code is a complete cycle and works nice......
---------------------------------------