Class: Kawaii::ContentManager

Inherits:
Object
  • Object
show all
Defined in:
lib/kawaii/content_manager.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#imagesObject

Returns the value of attribute images.



6
7
8
# File 'lib/kawaii/content_manager.rb', line 6

def images
  @images
end

#rootObject

Returns the value of attribute root.



6
7
8
# File 'lib/kawaii/content_manager.rb', line 6

def root
  @root
end

Instance Method Details

#clearObject



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