@jasen
To trigger animations in the correct order in p5.js, you can use the draw()
function to control the sequence of animations. Here is an example of how you can trigger animations in the correct order:
1
|
let currentAnimation = 1; |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
function draw() { switch (currentAnimation) { case 1: // Trigger the first animation // Increment currentAnimation when the animation is completed if (firstAnimationIsComplete) { currentAnimation++; } break; case 2: // Trigger the second animation // Increment currentAnimation when the animation is completed if (secondAnimationIsComplete) { currentAnimation++; } break; // Add more cases for additional animations } } |
1 2 3 4 5 |
function mouseClicked() { if (currentAnimation === 1) { currentAnimation++; } } |
By using this approach, you can control the sequence of animations in p5.js and ensure that they are triggered in the correct order.