Hello,
i’m trying to implement this example: https://p5js.org/reference/#/p5.Image/delay in a sketch, but when I run it i get the message “bg1.delay is not a function”. I believe my code is exactly the same as in the example. Do i need to use a specific library or something?
Thanks in advance!
let bg1, bg2;
function preload() {
bg1 = loadImage("deck/elBueno.gif");
bg2 = loadImage("deck/elBueno.gif");
}
function setup() {
createCanvas(480, 720);
bg1.resize(width / 2, height / 2);
bg2.resize(width / 2, height / 2);
bg1.delay(10);
bg2.delay(100);
}
function draw() {
background(0);
translate(width / 2, height / 2);
image(bg1, 0, 0);
image(bg2, 0, 0, width/2,0);
}
1 Like
glv
April 7, 2020, 4:16am
2
Hello,
It works fine here in the Processing P5.js mode.
I used this animated gif:
:)
1 Like
Thanks!!
I tried with your gif but same error
did you use the exact same code, just changed the file?
glv
April 7, 2020, 1:31pm
4
Hello,
It still works fine here in the Processing P5.js mode and with the P5 Editor.
I modified code but it worked with original as well.
let bg1, bg2;
function preload()
{
bg1 = loadImage('giphy.gif');
bg2 = loadImage('giphy.gif');
}
function setup()
{
createCanvas(800, 450);
//bg1.resize(width / 2, height / 2);
//bg2.resize(width / 2, height / 2);
bg1.delay(10);
bg2.delay(100);
}
function draw()
{
background(0);
//translate(width / 2, height / 2);
image(bg1, 0, 0);
image(bg2, width/2, 0);
}
:)
2 Likes