Animation Loop throwing an error

Solution: I figured it out. I needed to add the following to the top of the file


I'm trying to create an animation and I'm able to get the image table to work, but when I try to use an animation loop, I see this exception:

main.lua:129: attempt to index a nil value (field 'animation')

Here is the source for what I'm trying to do:

local imagetable ='Images/ship')
assert(imagetable, error)
-- This works great!
imagetable:getImage(1):draw(100, 100)
-- This throws the above error
local animation =, imagetable)

Any ideas what I'm doing wrong here? Thanks!

When you'll get tired from build-in animation solution, please take a look at my AnimatedSprite class: