Hi, I need help with this unusual problem.
I have class where in function SmallCloud:init I initializing self.id. Here variable works, also in SmallCloud:draw() function. But when I call SmallCloud:update function, here have variable self.id a nil value. Why?
Code:
SmallCloud = class()
function SmallCloud:init(id,x,y,strana,pocet,ciel,rychlost)
self.id=id
self.x=x
self.y=y
self.strana=strana
self.pocet=pocet
self.ciel=ciel
self.rychlost=rychlost
end
function SmallCloud:draw()
pushStyle()
if self.strana==1 then
sprite("Dropbox:modry",self.x,self.y,40+self.pocet)
fill(0,173,238,255)
elseif self.strana==2 then
sprite("Dropbox:red",self.x,self.y,40+self.pocet)
fill(191,33,46)
elseif self.strana==3 then
sprite("Dropbox:orange",self.x,self.y,40+self.pocet)
fill(255,156,43)
end
font("SourceSansPro-Regular")
fontSize(25)
--text(self.pocet,self.x,self.y)
text(self.id,self.x,self.y)
popStyle()
end
function SmallCloud:update()
print(self.id)
end