Add Background Animation
Last updated
Last updated
The function below uses p5.js functions to create a spinning block that you can add to your app background.
1 - Add the following function to the bottom of your JavaScript.
2 - Now you simply need to call this function when you want it to display in the background. In the example below, spinningBlock( )
is called in the draw( )
function when the trivia game state is "welcome" on line 3. If you want, you can choose to call the function at a different point.
The spinningBlock is a simple example of adding an animation to your background, but you can come up with your own animation and call it something different than spinningBlock( )
.
For example, you may choose to create an animation that looks like balloons rising up and call it balloons( )
. It may be challenging, but you can use functions from the p5.js (as we did above for the spinning block) to create some really interesting animations.
Here are more examples of custom animation functions that could be implemented like the spinningBlock()
above.