I’ve spotted where my problem is. I’m not tinting the sprite as I’m using the animation engine @West created and shared - which is super awesome!
I suppose it’s knowing within that code where to place the tint
Here’s the code and you’ll see the if statement showing tint currently
Ship = class()
function Ship:init(x,y,w,h,image)
-- you can accept and set parameters here
self.x = x
self.y = y
self.w = w
self.h = h
self.units = {}
self.frame = 0
self.F=mesh()
self.img=readImage(image)
self.F.texture=self.img
self.rows=3 --number of rows in the sprite sheet
self.cols=3 -- number of columns in the sprite sheet
self.state=self.straight
--moaction=0
--constants
self.straight=0
self.left=1
self.right=2
self.deady=3
self.hit=false
--arrays to hold the animation
self.animdelay=0
self.amimdelaymax=3
self.animx={}
self.animy={}
--define the frames
--straight
self.animx[0]={1,1,1,1}
self.animy[0]={2,1,2,1}
--shipleft
self.animx[1]={0,0,0,0}
self.animy[1]={2,1,2,1}
--shipright
self.animx[2]={2,2,2,2}
self.animy[2]={2,1,2,1}
--dead
self.animx[3]={0,1,2,2}
self.animy[3]={0,0,0,0}
self.curFrame=1
end
function Ship:draw()
self.F:clear() --clear the mesh
--cycle through the animation
--add a delay to solw the animation down
self.animdelay = self.animdelay + 1
if self.animdelay>3 then
--move to the next frame in the animation
self.curFrame = self.curFrame + 1
if self.curFrame>#self.animx[self.state] and self.state==self.right then
self.state=self.right
self.curFrame=1
end
if self.curFrame>#self.animx[self.state] and self.state==self.left then
self.state=self.left
self.curFrame=1
end
if self.curFrame>#self.animx[self.state] and self.state==self.straight then
self.state=self.straight
self.curFrame=1
end
if self.curFrame>#self.animx[self.state] and self.state==self.deady then
self.state=self.deady
self.curFrame=4
end
--reset the animation delay counter
self.animdelay=0
end
local idx = self.F:addRect(self.x, self.y, self.w, self.h)
self.F:setRectTex(idx,(self.animx[self.state][self.curFrame])/self.cols,(self.animy[self.state][self.curFrame])/
self.rows,1/self.cols, 1/self.rows)
--draw the mesh
if self.hit==true then
tint(255,255,255,255)
self.hit=false
end
self.F:draw()
end