Gif as background rendered different than file

Hi everyone, I'm currently developping a little pong as my first game. I want to have an animation for the background of the game.
I've exported an animation with a P5js sketch https://editor.p5js.org/Erjaeger42/sketches/Est8hm1x2

Just a black and white animation. I've add it to my game with this code :

class("GameScene").extends(gfx.sprite)

function GameScene:init()
	GameScene.super.init(self)

	local backgroundTable = gfx.imagetable.new("assets/background_anim.gif")
	local animationLoop = gfx.animation.loop.new(10, backgroundTable, true)
	local animatedSprite = gfx.sprite.new(animationLoop:image())
	animatedSprite:setZIndex(0)
	animatedSprite:setBounds(0, 0, 400, 240)
	animatedSprite:add()
	animatedSprite.update = function()
		gfx.setImageDrawMode(gfx.kDrawModeCopy)
		animatedSprite:setImage(animationLoop:image())
	end

	self:launchGame()
end

But the result looks like this :
background

I've tried to set different ImageDrawMode but it's not changing anything.

Am I missing something ? Is it better to generate multiple image and then create the animation with an ImageTable instead of using a GIF?

Thanks for your help!

Hi Matt,

I tried it but no difference. I've tried exporting only one image from the p5 sketch. And it's correctly working. Also for my introduction I've created an animation with Procreate on the ipad and the animation is correctly displayed.

My guess is the gif generated has a problem or a different encoding (not sure this is a thing for images).

My bad, the link is updated and here's the animation.
myAnim (5)

I tried splitting the GIF in frames, loading it with an ImageTable and it's working!

working_anim

I also tried to create a gif with the website you linked, and it's also working.

I have an other problem but that's not link to the gif itself, I put the line gfx.setImageDrawMode(gfx.kDrawModeXOR) before drawing my image from the animation, but I don't have any XOR effect with the sprites already on screen. I have misunderstanding something I think.

Thanks for your help!

Indeed. Thank you for your help, it's working great!