Skip to content

Frame Indipendent Animation #36

@ariutti

Description

@ariutti

Dobbiamo animare su base del tempo piuttosto che su base del frame. Così facendo si resta sostanzialmente indipendenti da eventuali accelerazioni o rallentamenti nella velocità dell'FPS dell'applicazione.

Utile a tale scopo potrebbe essere la funzione ofGetLastFrameTime di ofAppRunner.

Interessante a tale proposito il paragrafo sulla animazione nel libro ofBook


Altre funzioni del tempo che potrebbero essere utili per l'animazione sono (della classe ofUtils):

  • ofGetElapsedTimef() - returns the elapsed time in floating point numbers, starting from 0 when the app starts;
  • ofGetElapsedTimeMillis() - similarly returns the elapsed time starting from 0 in milliseconds.
  • ofGetFrameNum() - returns the number of frames the software has drawn. If you wanted, for example, to do something every other frame you could use the mod operator, e.g., if (ofGetFrameNum() % 2 == 0).

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions