42 setAnimation - JcerelusDev/CanvasGameJs GitHub Wiki

What is setAnimation ?

Is responsible for your game loop Without it the game can't run

It requires one argument which is the amount of fps.

That gives you full control over the game loop , it is useful according to the type of game you are developing.

 game.setAnimation(fps)
// this is the main loop
 game.setAnimation(60)

That method is also used to resume game after being paused by using the previous method stopAnimation.

Code Example :

Do the following inside of your resume game function after being paused.

function resume(){
game.setAnimation(60)
}
Good to know :

You can control animation's speed by using the following : frame