Represents a time value. More...
#include <Time.hpp>
Public Member Functions | |
Time () | |
Default constructor. | |
float | asSeconds () const |
Return the time value as a number of seconds. | |
Int32 | asMilliseconds () const |
Return the time value as a number of milliseconds. | |
Int64 | asMicroseconds () const |
Return the time value as a number of microseconds. | |
Static Public Attributes | |
static const Time | Zero |
Predefined "zero" time value. | |
Friends | |
Time | seconds (float) |
Time | milliseconds (Int32) |
Time | microseconds (Int64) |
Related Functions | |
(Note that these are not member functions.) | |
Time | seconds (float amount) |
Construct a time value from a number of seconds. | |
Time | milliseconds (Int32 amount) |
Construct a time value from a number of milliseconds. | |
Time | microseconds (Int64 amount) |
Construct a time value from a number of microseconds. | |
bool | operator== (Time left, Time right) |
Overload of == operator to compare two time values. | |
bool | operator!= (Time left, Time right) |
Overload of != operator to compare two time values. | |
bool | operator< (Time left, Time right) |
Overload of < operator to compare two time values. | |
bool | operator> (Time left, Time right) |
Overload of > operator to compare two time values. | |
bool | operator<= (Time left, Time right) |
Overload of <= operator to compare two time values. | |
bool | operator>= (Time left, Time right) |
Overload of >= operator to compare two time values. | |
Time | operator- (Time right) |
Overload of unary - operator to negate a time value. | |
Time | operator+ (Time left, Time right) |
Overload of binary + operator to add two time values. | |
Time & | operator+= (Time &left, Time right) |
Overload of binary += operator to add/assign two time values. | |
Time | operator- (Time left, Time right) |
Overload of binary - operator to subtract two time values. | |
Time & | operator-= (Time &left, Time right) |
Overload of binary -= operator to subtract/assign two time values. | |
Time | operator* (Time left, float right) |
Overload of binary * operator to scale a time value. | |
Time | operator* (Time left, Int64 right) |
Overload of binary * operator to scale a time value. | |
Time | operator* (float left, Time right) |
Overload of binary * operator to scale a time value. | |
Time | operator* (Int64 left, Time right) |
Overload of binary * operator to scale a time value. | |
Time & | operator*= (Time &left, float right) |
Overload of binary *= operator to scale/assign a time value. | |
Time & | operator*= (Time &left, Int64 right) |
Overload of binary *= operator to scale/assign a time value. | |
Time | operator/ (Time left, float right) |
Overload of binary / operator to scale a time value. | |
Time | operator/ (Time left, Int64 right) |
Overload of binary / operator to scale a time value. | |
Time & | operator/= (Time &left, float right) |
Overload of binary /= operator to scale/assign a time value. | |
Time & | operator/= (Time &left, Int64 right) |
Overload of binary /= operator to scale/assign a time value. | |
Represents a time value.
sf::Time encapsulates a time value in a flexible way.
It allows to define a time value either as a number of seconds, milliseconds or microseconds. It also works the other way round: you can read a time value as either a number of seconds, milliseconds or microseconds.
By using such a flexible interface, the API doesn't impose any fixed type or resolution for time values, and let the user choose its own favorite representation.
Time values support the usual mathematical operations: you can add or subtract two times, multiply or divide a time by a number, compare two times, etc.
Since they represent a time span and not an absolute time value, times can also be negative.
Usage example:
sf::Time::Time | ( | ) |
Default constructor.
Sets the time value to zero.
Int64 sf::Time::asMicroseconds | ( | ) | const |
Return the time value as a number of microseconds.
Int32 sf::Time::asMilliseconds | ( | ) | const |
Return the time value as a number of milliseconds.
float sf::Time::asSeconds | ( | ) | const |
Return the time value as a number of seconds.
|
related |
Construct a time value from a number of microseconds.
amount | Number of microseconds |
|
related |
Construct a time value from a number of milliseconds.
amount | Number of milliseconds |
Overload of != operator to compare two time values.
left | Left operand (a time) |
right | Right operand (a time) |
Overload of binary * operator to scale a time value.
left | Left operand (a time) |
right | Right operand (a number) |
Overload of binary * operator to scale a time value.
left | Left operand (a time) |
right | Right operand (a number) |
Overload of binary * operator to scale a time value.
left | Left operand (a number) |
right | Right operand (a time) |
Overload of binary * operator to scale a time value.
left | Left operand (a number) |
right | Right operand (a time) |
Overload of binary *= operator to scale/assign a time value.
left | Left operand (a time) |
right | Right operand (a number) |
Overload of binary *= operator to scale/assign a time value.
left | Left operand (a time) |
right | Right operand (a number) |
Overload of binary + operator to add two time values.
left | Left operand (a time) |
right | Right operand (a time) |
Overload of binary += operator to add/assign two time values.
left | Left operand (a time) |
right | Right operand (a time) |
Overload of unary - operator to negate a time value.
right | Right operand (a time) |
Overload of binary - operator to subtract two time values.
left | Left operand (a time) |
right | Right operand (a time) |
Overload of binary -= operator to subtract/assign two time values.
left | Left operand (a time) |
right | Right operand (a time) |
Overload of binary / operator to scale a time value.
left | Left operand (a time) |
right | Right operand (a number) |
Overload of binary / operator to scale a time value.
left | Left operand (a time) |
right | Right operand (a number) |
Overload of binary /= operator to scale/assign a time value.
left | Left operand (a time) |
right | Right operand (a number) |
Overload of binary /= operator to scale/assign a time value.
left | Left operand (a time) |
right | Right operand (a number) |
Overload of < operator to compare two time values.
left | Left operand (a time) |
right | Right operand (a time) |
Overload of <= operator to compare two time values.
left | Left operand (a time) |
right | Right operand (a time) |
Overload of == operator to compare two time values.
left | Left operand (a time) |
right | Right operand (a time) |
Overload of > operator to compare two time values.
left | Left operand (a time) |
right | Right operand (a time) |
Overload of >= operator to compare two time values.
left | Left operand (a time) |
right | Right operand (a time) |
|
related |
Construct a time value from a number of seconds.
amount | Number of seconds |
|
static |