GSDP:GAM100/CProcessing/setFrameRate()

From Inside
Jump to: navigation, search

setFrameRate()

Description

Lets you set how many frames your program will run per second.

Parameters

setFrameRate(float fps)

  • fps - (float) The new frame rate in frames per second.

Example

void init()
{
  // Set frame rate to two frame a second
  setFrameRate(2.0f);

  // Set parameters of the text
  fill(color(0, 0, 0, 255));
  textSize(64);
  textAlign(CP_ALIGN_H_CENTER, CP_ALIGN_V_MIDDLE);
}

void update()
{
  background(color(255, 255, 255, 255));

  // Create a string with the frame rate 
  char buffer[128] = { 0 };
  sprintf_s(buffer, 128, "%d frames have elapsed", frameCount);

  // Draw to the screen
  text(buffer, (float)canvasWidth / 2.0f, (float)canvasHeight / 2.0f);
}

Related

Personal tools
Namespaces

Variants
Actions
Navigation
NameSpaces:>
Tools
Dynamic:>