Probably my missing something, but in the following code (simplified to show the problem)
Block = class()
function Block:init(x,y)
-- you can accept and set parameters here
self.x = x
self.y = y
self.model = "Planet Cute:Gem Blue"
end
function Block:draw()
-- Codea does not automatically call this method
sprite("Planet Cute:Gem Blue", self.x, 100)
end
function Block:touched(touch)
-- Codea does not automatically call this method
end
the “self.x” usage in sprite generates an error – “attempt to index local ‘self’ (a nil value)”
Any idea why? What I’m missing?
My main.lua is
function setup()
block = Block(200,200)
end
-- This function gets called once every frame
function draw()
-- This sets a dark background color
background(40, 40, 50)
block.draw()
end
Thanks