How do i create animation with my sprite with a sprite map?

I have an image which is width 150 and height 50 that contains 3 frames of animation. Each frame is 50 x 50.
I want to mask the other frames while just showing one to give the illusion of animation.
I made a Countdown class that extends Sprites
The way I did it was I added a ClipRect to the image and I move the image while the ClipRect stays still.
The problem is i can't use moveTo and i feel like i'm losing out on other sprite functions because if I move the sprite it goes out of sync with the mask. I had to write a custom move. here is the code


--frameW and frameH are the width and height of a frame
--the image is an image map of multiple frames

function Countdown:init(frameW, frameH,image)
    self.currentFrame = 1

    --Load Image
   local newImage =
   self.frameW = frameX
   self.frameH = frameY

    --Get Image Data for calculations
    self.newImageW, self.newImageH  = self:getImage():getSize()
    self:setCenter(0, 0)


function Countdown:setFrame(frame)
    self.currentFrame = frame

function Countdown:drawUpdate(x,y)
    local frame =  self.currentFrame - 1  
    local spriteX = x - (self.frameW * frame)
    local spriteY = y
    local clipBoxCord = , y, self.frameW , self.frameH)


And in the main file
I just call :add() and :setFrame(1) or 2 3 etc. And :drawUpdate in the update script

This thing works but i just dont like how its written there must be a better way

I think what you are looking for is Image Table.


thank you, can't believe i missed that in the docs. thank you