Method: Numeric#second

Defined in:
lib/core_ext/numeric.rb

#secondObject Also known as: seconds, secs, sec

Provides the suffix ‘second’ which will translate seconds to game ticks. This is to allow for a number of seconds to be expressed in situations where game ticks are used (e.g. animations).

Examples:

Expressing an animation that takes place over 3 seconds (~180 ticks)


class ExampleScene < Metro::Scene
  draws :title

  animate :title, to: { x: 320, y: 444 }, interval: 3.seconds
end


33
34
35
# File 'lib/core_ext/numeric.rb', line 33

def second
  (self * 1000 / Numeric.tick_interval).floor
end