Reputation: 193
I have a local GIF file, and I want to assign the output to a sprite.
I have the following libraries in use, if it matters at all :-
Also, I don't want to split the GIF into separate images.
Upvotes: 0
Views: 974
Reputation: 20180
If you are talking about p5.play sprites specifically you'll need to be more explicit with your question. However, generally speaking using animated gifs in p5.js is very straightforward. You can just load and draw them like any other image using the loadImage
and image
functions.
let gif;
function preload() {
gif = loadImage('https://www.paulwheeler.us/files/EQ1QT.gif');
}
function setup() {
createCanvas(windowWidth, windowHeight);
}
function draw() {
background(255);
image(gif, mouseX - 20, mouseY - 20, 40, 40);
}
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/p5.js"></script>
Upvotes: 1