sfml3.rb

Class: SFML::Clock

Inherits:
Object
  • Object
show all
Defined in:
ext/system/clock.c,
ext/system/clock.c

Overview

A stopwatch for measuring elapsed time.

Instance Method Summary collapse

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.

Returns:

Returns:

  • (Clock) —

    an independent copy with the same elapsed/running state



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.

Returns:

Returns:

  • (Time) —

    time elapsed since the clock was created, started, or last restarted/reset, whichever is most recent



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.

Returns:

Returns:



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.

Returns:

Returns:



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.

Returns:

  • (Boolean)

Returns:

  • (Boolean)


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.

Returns:

  • (self)

Returns:

  • (self)


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.

Returns:

  • (self)

Returns:

  • (self)


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;
}