Represents a time value. More...
#include <Time.hpp>
Public Member Functions | |
Time () | |
Default constructor. More... | |
float | asSeconds () const |
Return the time value as a number of seconds. More... | |
Int32 | asMilliseconds () const |
Return the time value as a number of milliseconds. More... | |
Int64 | asMicroseconds () const |
Return the time value as a number of microseconds. More... | |
Static Public Attributes | |
static const Time | Zero |
Predefined "zero" time value. More... | |
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. More... | |
Time | milliseconds (Int32 amount) |
Construct a time value from a number of milliseconds. More... | |
Time | microseconds (Int64 amount) |
Construct a time value from a number of microseconds. More... | |
bool | operator== (Time left, Time right) |
Overload of == operator to compare two time values. More... | |
bool | operator!= (Time left, Time right) |
Overload of != operator to compare two time values. More... | |
bool | operator< (Time left, Time right) |
Overload of < operator to compare two time values. More... | |
bool | operator> (Time left, Time right) |
Overload of > operator to compare two time values. More... | |
bool | operator<= (Time left, Time right) |
Overload of <= operator to compare two time values. More... | |
bool | operator>= (Time left, Time right) |
Overload of >= operator to compare two time values. More... | |
Time | operator- (Time right) |
Overload of unary - operator to negate a time value. More... | |
Time | operator+ (Time left, Time right) |
Overload of binary + operator to add two time values. More... | |
Time & | operator+= (Time &left, Time right) |
Overload of binary += operator to add/assign two time values. More... | |
Time | operator- (Time left, Time right) |
Overload of binary - operator to subtract two time values. More... | |
Time & | operator-= (Time &left, Time right) |
Overload of binary -= operator to subtract/assign two time values. More... | |
Time | operator* (Time left, float right) |
Overload of binary * operator to scale a time value. More... | |
Time | operator* (Time left, Int64 right) |
Overload of binary * operator to scale a time value. More... | |
Time | operator* (float left, Time right) |
Overload of binary * operator to scale a time value. More... | |
Time | operator* (Int64 left, Time right) |
Overload of binary * operator to scale a time value. More... | |
Time & | operator*= (Time &left, float right) |
Overload of binary *= operator to scale/assign a time value. More... | |
Time & | operator*= (Time &left, Int64 right) |
Overload of binary *= operator to scale/assign a time value. More... | |
Time | operator/ (Time left, float right) |
Overload of binary / operator to scale a time value. More... | |
Time | operator/ (Time left, Int64 right) |
Overload of binary / operator to scale a time value. More... | |
Time & | operator/= (Time &left, float right) |
Overload of binary /= operator to scale/assign a time value. More... | |
Time & | operator/= (Time &left, Int64 right) |
Overload of binary /= operator to scale/assign a time value. More... | |
float | operator/ (Time left, Time right) |
Overload of binary / operator to compute the ratio of two time values. More... | |
Time | operator% (Time left, Time right) |
Overload of binary % operator to compute remainder of a time value. More... | |
Time & | operator%= (Time &left, Time right) |
Overload of binary %= operator to compute/assign remainder of a time value. More... | |
Detailed Description
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:
- See also
- sf::Clock
Constructor & Destructor Documentation
sf::Time::Time | ( | ) |
Default constructor.
Sets the time value to zero.
Member Function Documentation
Int64 sf::Time::asMicroseconds | ( | ) | const |
Return the time value as a number of microseconds.
- Returns
- Time in microseconds
- See also
- asSeconds, asMilliseconds
Int32 sf::Time::asMilliseconds | ( | ) | const |
Return the time value as a number of milliseconds.
- Returns
- Time in milliseconds
- See also
- asSeconds, asMicroseconds
float sf::Time::asSeconds | ( | ) | const |
Return the time value as a number of seconds.
- Returns
- Time in seconds
- See also
- asMilliseconds, asMicroseconds
Friends And Related Function Documentation
|
related |
Construct a time value from a number of microseconds.
- Parameters
-
amount Number of microseconds
- Returns
- Time value constructed from the amount of microseconds
- See also
- seconds, milliseconds
|
related |
Construct a time value from a number of milliseconds.
- Parameters
-
amount Number of milliseconds
- Returns
- Time value constructed from the amount of milliseconds
- See also
- seconds, microseconds
Overload of != operator to compare two time values.
- Parameters
-
left Left operand (a time) right Right operand (a time)
- Returns
- True if both time values are different
Overload of binary % operator to compute remainder of a time value.
- Parameters
-
left Left operand (a time) right Right operand (a time)
- Returns
- left modulo right
Overload of binary %= operator to compute/assign remainder of a time value.
- Parameters
-
left Left operand (a time) right Right operand (a time)
- Returns
- left modulo right
Overload of binary * operator to scale a time value.
- Parameters
-
left Left operand (a time) right Right operand (a number)
- Returns
- left multiplied by right
Overload of binary * operator to scale a time value.
- Parameters
-
left Left operand (a time) right Right operand (a number)
- Returns
- left multiplied by right
Overload of binary * operator to scale a time value.
- Parameters
-
left Left operand (a number) right Right operand (a time)
- Returns
- left multiplied by right
Overload of binary * operator to scale a time value.
- Parameters
-
left Left operand (a number) right Right operand (a time)
- Returns
- left multiplied by right
Overload of binary *= operator to scale/assign a time value.
- Parameters
-
left Left operand (a time) right Right operand (a number)
- Returns
- left multiplied by right
Overload of binary *= operator to scale/assign a time value.
- Parameters
-
left Left operand (a time) right Right operand (a number)
- Returns
- left multiplied by right
Overload of binary + operator to add two time values.
- Parameters
-
left Left operand (a time) right Right operand (a time)
- Returns
- Sum of the two times values
Overload of binary += operator to add/assign two time values.
- Parameters
-
left Left operand (a time) right Right operand (a time)
- Returns
- Sum of the two times values
Overload of unary - operator to negate a time value.
- Parameters
-
right Right operand (a time)
- Returns
- Opposite of the time value
Overload of binary - operator to subtract two time values.
- Parameters
-
left Left operand (a time) right Right operand (a time)
- Returns
- Difference of the two times values
Overload of binary -= operator to subtract/assign two time values.
- Parameters
-
left Left operand (a time) right Right operand (a time)
- Returns
- Difference of the two times values
Overload of binary / operator to scale a time value.
- Parameters
-
left Left operand (a time) right Right operand (a number)
- Returns
- left divided by right
Overload of binary / operator to scale a time value.
- Parameters
-
left Left operand (a time) right Right operand (a number)
- Returns
- left divided by right
Overload of binary / operator to compute the ratio of two time values.
- Parameters
-
left Left operand (a time) right Right operand (a time)
- Returns
- left divided by right
Overload of binary /= operator to scale/assign a time value.
- Parameters
-
left Left operand (a time) right Right operand (a number)
- Returns
- left divided by right
Overload of binary /= operator to scale/assign a time value.
- Parameters
-
left Left operand (a time) right Right operand (a number)
- Returns
- left divided by right
Overload of < operator to compare two time values.
- Parameters
-
left Left operand (a time) right Right operand (a time)
- Returns
- True if left is lesser than right
Overload of <= operator to compare two time values.
- Parameters
-
left Left operand (a time) right Right operand (a time)
- Returns
- True if left is lesser or equal than right
Overload of == operator to compare two time values.
- Parameters
-
left Left operand (a time) right Right operand (a time)
- Returns
- True if both time values are equal
Overload of > operator to compare two time values.
- Parameters
-
left Left operand (a time) right Right operand (a time)
- Returns
- True if left is greater than right
Overload of >= operator to compare two time values.
- Parameters
-
left Left operand (a time) right Right operand (a time)
- Returns
- True if left is greater or equal than right
|
related |
Construct a time value from a number of seconds.
- Parameters
-
amount Number of seconds
- Returns
- Time value constructed from the amount of seconds
- See also
- milliseconds, microseconds
Member Data Documentation
|
static |
The documentation for this class was generated from the following file: