Class: SFML::Clock
- Inherits:
-
Object
- Object
- SFML::Clock
- Defined in:
- ext/system/clock.c,
ext/system/clock.c
Overview
A stopwatch for measuring elapsed time.
Instance Method Summary collapse
-
#copy ⇒ Clock
Returns an independent copy of the clock.
-
#elapsed_time ⇒ Time
Returns the time elapsed on the clock.
-
#new ⇒ Clock
constructor
Creates a new clock and starts it immediately.
-
#reset! ⇒ Time
Stops the clock and resets its elapsed time to zero, returning the time elapsed before resetting.
-
#restart! ⇒ Time
Restarts the clock (equivalent to #reset! followed by #start!) and returns the time elapsed before restarting.
-
#running? ⇒ Boolean
Returns
truewhile the clock is running,falseonce it is stopped. -
#start! ⇒ self
Resumes a stopped clock without resetting its elapsed time.
-
#stop! ⇒ self
Pauses the clock; #elapsed_time keeps returning the time at which it was stopped until #start! or #restart! is called.
Constructor Details
#new ⇒ Clock
Creates a new clock and starts it immediately.
56 57 58 |
# File 'ext/system/clock.c', line 56 static VALUE Clock_init(VALUE self) { return self; } |
Instance Method Details
#copy ⇒ Clock
Returns an independent copy of the clock.
132 133 134 |
# File 'ext/system/clock.c', line 132 static VALUE Clock_copy(VALUE self) { return Clock_new_from(Get_Klass_Clock(), sfClock_copy(Get_Clock_Struct(self))); } |
#elapsed_time ⇒ Time
Returns the time elapsed on the clock.
67 68 69 |
# File 'ext/system/clock.c', line 67 static VALUE Clock_get_elapsed_time(VALUE self) { return time_to_rb(sfClock_getElapsedTime(Get_Clock_Struct(self))); } |
#reset! ⇒ Time
Stops the clock and resets its elapsed time to zero, returning the time elapsed before resetting.
89 90 91 |
# File 'ext/system/clock.c', line 89 static VALUE Clock_reset(VALUE self) { return time_to_rb(sfClock_reset(Get_Clock_Struct(self))); } |
#restart! ⇒ Time
Restarts the clock (equivalent to #reset! followed by #start!) and returns the time elapsed before restarting.
78 79 80 |
# File 'ext/system/clock.c', line 78 static VALUE Clock_restart(VALUE self) { return time_to_rb(sfClock_restart(Get_Clock_Struct(self))); } |
#running? ⇒ Boolean
Returns true while the clock is running, false once it is stopped.
99 100 101 |
# File 'ext/system/clock.c', line 99 static VALUE Clock_is_running(VALUE self) { return BOOL2RB(sfClock_isRunning(Get_Clock_Struct(self))); } |
#start! ⇒ self
Resumes a stopped clock without resetting its elapsed time.
109 110 111 112 |
# File 'ext/system/clock.c', line 109 static VALUE Clock_start(VALUE self) { sfClock_start(Get_Clock_Struct(self)); return self; } |
#stop! ⇒ self
Pauses the clock; #elapsed_time keeps returning the time at which it was stopped until #start! or #restart! is called.
121 122 123 124 |
# File 'ext/system/clock.c', line 121 static VALUE Clock_stop(VALUE self) { sfClock_stop(Get_Clock_Struct(self)); return self; } |