Animation Loops & requestAnimationFrame()

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/14

encourage image

There's no tags or description

Looks like no tags are added yet.

15 Terms

1
New cards

What is an animation loop?

A repeated process of updating and redrawing a scene to create movement.

2
New cards

What does requestAnimationFrame() do?

Asks the browser to schedule a function for the next animation frame.

3
New cards

What is the purpose of animate() in an animation?

It contains the instructions for updating and drawing each frame.

4
New cards

Why is animate() called at the end of the code?

To start the animation for the first time.

5
New cards

What are the three basic steps in a Canvas animation loop?

Clear the canvas, update the object's state, and draw the scene again.

6
New cards

Why is clearRect() used in an animation loop?

To erase the previous frame before drawing the updated scene.

7
New cards

What does x = x + 2 do in an animation?

Increases the x-position by two, moving the object right.

8
New cards

What happens if x increases but y stays the same?

The object moves horizontally.

9
New cards

What happens if y increases but x stays the same?

The object moves downwards.

10
New cards

What does ctx.arc() do?

Creates a circular or curved path.

11
New cards

What does ctx.fill() do?

Fills the current path with the selected fill colour.

12
New cards

What is a frame in animation?

One individual drawing or image in an animation sequence.

13
New cards

Why must an animation loop repeat?

To continually update and redraw the scene so movement appears continuous.

14
New cards

What is the correct order of a basic animation loop?

Clear, update, draw, then schedule the next frame.

15
New cards

Why can movement based on pixels per frame vary in speed?

The browser's frame rate can change, affecting how far an object moves per second.