Class: Kawaii::ContentManager
- Inherits:
-
Object
- Object
- Kawaii::ContentManager
- Defined in:
- lib/kawaii/content_manager.rb
Instance Attribute Summary collapse
-
#images ⇒ Object
Returns the value of attribute images.
-
#root ⇒ Object
Returns the value of attribute root.
Instance Method Summary collapse
- #clear ⇒ Object
-
#initialize(window, root) ⇒ ContentManager
constructor
A new instance of ContentManager.
-
#load_image(path, tileable = false) ⇒ Object
loads an image and caches it for further use if an image has been loaded it is just being returned.
- #load_tiled_images(path, cell_size) ⇒ Object
Constructor Details
#initialize(window, root) ⇒ ContentManager
Returns a new instance of ContentManager.
8 9 10 11 12 |
# File 'lib/kawaii/content_manager.rb', line 8 def initialize window, root @window = window @root = root @images = {} end |
Instance Attribute Details
#images ⇒ Object
Returns the value of attribute images.
6 7 8 |
# File 'lib/kawaii/content_manager.rb', line 6 def images @images end |
#root ⇒ Object
Returns the value of attribute root.
6 7 8 |
# File 'lib/kawaii/content_manager.rb', line 6 def root @root end |
Instance Method Details
#clear ⇒ Object
14 15 16 |
# File 'lib/kawaii/content_manager.rb', line 14 def clear @images.clear end |
#load_image(path, tileable = false) ⇒ Object
loads an image and caches it for further use if an image has been loaded it is just being returned
20 21 22 23 24 25 |
# File 'lib/kawaii/content_manager.rb', line 20 def load_image(path, tileable = false) if !@images[path] @images[path] = Gosu::Image.new(@window, "#{@root}/#{path}", tileable) end @images[path] end |
#load_tiled_images(path, cell_size) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/kawaii/content_manager.rb', line 27 def load_tiled_images(path, cell_size) if !@images[path] @images[path] = Gosu::Image.load_tiles(@window, "#{@root}/#{path}", cell_size, cell_size, true) end @images[path] end |