Class: Metro::UI::FPS
Constant Summary
Constants included from Metro::Units
Instance Attribute Summary
Attributes inherited from Model
Instance Method Summary collapse
Methods inherited from Model
#_load, #_save, #after_initialize, #bounds, #create, #draw_completed?, hierarchy, inherited, #initialize, metro_name, #model, model_name, models, #name, #notification, #saveable_to_view, #to_hash, #update_completed?
Methods included from HasEvents
Methods included from KeyValueCoding
Methods included from PropertyOwner
Constructor Details
This class inherits a constructor from Metro::Model
Instance Method Details
#draw ⇒ Object
47 48 49 |
# File 'lib/metro/models/ui/fps.rb', line 47 def draw label.draw end |
#place_label ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/metro/models/ui/fps.rb', line 35 def place_label placement_hash = valid_placements[placement.to_sym] label.align = placement_hash[:align] label.vertical_align = placement_hash[:vertical_align] label.position = placement_hash[:position] end |
#show ⇒ Object
31 32 33 |
# File 'lib/metro/models/ui/fps.rb', line 31 def show place_label end |
#update ⇒ Object
43 44 45 |
# File 'lib/metro/models/ui/fps.rb', line 43 def update label.text = "FPS: #{Gosu.fps}" end |
#valid_placements ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/metro/models/ui/fps.rb', line 13 def valid_placements @valid_placements ||= begin { top_left: { position: Game.bounds.top_left, align: 'left', vertical_align: 'top' }, top: { position: Point.at(Game.center.x, Game.bounds.top), align: 'center', vertical_align: 'top' }, top_right: { position: Game.bounds.top_right, align: 'right', vertical_align: 'top' }, right: { position: Point.at(Game.bounds.right, Game.center.y), align: 'right', vertical_align: 'center' }, bottom_right: { position: Game.bounds.bottom_right, align: 'right', vertical_align: 'bottom' }, bottom: { position: Point.at(Game.center.x, Game.bounds.bottom), align: 'right', vertical_align: 'bottom' }, bottom_left: { position: Game.bounds.bottom_right, align: 'left', vertical_align: 'bottom' }, left: { position: Point.at(Game.bounds.left, Game.center.y), align: 'left', vertical_align: 'center' } } end @valid_placements.default = :top @valid_placements end |