Hi! I am creating an animation with the following code
import "constants"
import "CoreLibs/animation"
local pd <const> = playdate
local gfx <const> = playdate.graphics
class('Book').extends(gfx.sprite)
menuPosition = 1
function Book:init(x,y)
local cursorImage = gfx.image.new("img/book.png")
IMAGETABLE = gfx.imagetable.new("img/book")
self:setImage(IMAGETABLE:getImage(1))
self:setCenter(0,0)
self.animation = gfx.animation.loop.new(150,IMAGETABLE,false)
self:add()
end
function Book:update()
self:setImage(self.animation:image())
if pd.buttonJustPressed(pd.kButtonA) then
self.animation:play()
end
end
And it works. It play the first time on load of the sprite. But I got Nil object when I press A.
What am I getting wrong?
thx!