World.frameCount

Category:Game Lab

The number of frames that have been displayed since the program started.

frameCount is incremented once for every execution of the draw() loop. frameCount is a variable that you do not need to declare. frameRate is the number of times per second the screen is refreshed is also the speed of draw() loop. The default rate of 30 frames per second.

Examples

Timer

Make a timer using frameCount and the default frameRate.

// Make a timer using frameCount and the default frameRate.
function draw() {
  background("white");
  textSize(25);
  text(Math.round(World.frameCount/30), 200, 200);
}

Syntax

World.frameCount

Returns

The number of frames that have been displayed since the program started.

Found a bug in the documentation? Let us know at documentation@code.org