I can’t work out why this simple code will not work. I have created a class called mysprite which I am trying to pass position/size values to. Printing the self values indicates that the values in the initial setup are being stored however the static image name in the draw function of mysprite will only position itself at 0,0.
What fundamental concept am I missing?
function setup()
s1 = mysprite(10,20,30,40)
s2 = mysprite(50,50,500,100)
end
function draw()
s1:draw()
s2:draw()
end
function touched(touch)
end
mysprite = class()
function mysprite:init(a,b,x,y)
-- you can accept and set parameters here
self.a = a
self.b = b
self.x = x
self.y = y
end
function mysprite:draw()
-- Codea does not automatically call this method
print(self.x)
print(self.y)
print(self.a)
print(self.b)
sprite("Platformer Art:Block Brick",self.x,self.y,self,a,self.b)
end
function mysprite:touched(touch)
-- Codea does not automatically call this method
end
t2i8