class Rubygame::Events::ClockTicked

ClockTicked is an event returned by Rubygame::Clock#tick, if the Clock has been configured with Rubygame::Clock#enable_tick_events.

ClockTicked stores the time that has passed since the previous tick. You can access that information with seconds or milliseconds. This is useful to calculate how far a character should move during the current frame, for example.

Public Class Methods

new( milliseconds ) click to toggle source

Create a new ClockTicked event.

milliseconds

The time since the last tick, in milliseconds. (Numeric, required)

# File lib/rubygame/events/clock_events.rb, line 42
def initialize( milliseconds )
  @milliseconds = milliseconds
end

Public Instance Methods

milliseconds() click to toggle source

Return the time since the last tick, in milliseconds.

# File lib/rubygame/events/clock_events.rb, line 47
def milliseconds
  @milliseconds
end
seconds() click to toggle source

Return the time since the last tick, in seconds.

# File lib/rubygame/events/clock_events.rb, line 52
def seconds
  @seconds or (@seconds = @milliseconds * 0.001)
end