I wrote a function two flip back and forth between 2 sprites (see below), I'm using setVisible to [show sprite 1 - hide sprite 2] then [hide sprite 1 show sprite 2] but it's not working, I'm thinking it actually has something to do with updating the sprites afterward but I can't figure it out.
It starts out right (with sprite 2 hidden and sprite 1 showing) then after second sprite 2 shows up but sprite 1 doesn't hide.
function AnimateHelo()
local helo_01 = playdate.graphics.sprite.new()
local helo_01_img = playdate.graphics.image.new("images/helo_01.png")
helo_01:setImage(helo_01_img)
helo_01:setCenter( 0.0, 0.0 )
helo_01:moveTo(281, 27)
helo_01:add()
local helo_02 = playdate.graphics.sprite.new()
local helo_02_img = playdate.graphics.image.new("images/helo_02.png")
helo_02:setImage(helo_02_img)
helo_02:setCenter( 0.0, 0.0 )
helo_02:moveTo(281, 27)
helo_02:add()
delay -= 1
if delay < 0 then
delay = 30
helo_frame +=1
if helo_frame > 2 then
helo_frame = 1
end
end
if helo_frame == 1 then
helo_01:setVisible(true)
helo_02:setVisible(false)
elseif helo_frame == 2 then
helo_01:setVisible(false)
helo_02:setVisible(true)
end
end