class SK::ContentManager
Attributes
content_root[RW]
Public Class Methods
new(window, content_root, nearest_filtering = false)
click to toggle source
# File lib/shirokuro/content/content_manager.rb, line 6 def initialize window, content_root, nearest_filtering = false @window = window @cache = {} @content_root = content_root.end_with?("/") ? content_root : "#{content_root}/" @nearest_filtering = nearest_filtering end
Public Instance Methods
load_image(name)
click to toggle source
# File lib/shirokuro/content/content_manager.rb, line 13 def load_image(name) asset_name = "#{@content_root}#{name}" unless @cache[asset_name] == nil return @cache[asset_name] end @cache[asset_name] = Gosu::Image.new(@window, asset_name) if @nearest_filtering @cache[asset_name].retro! end return load_image(name) end
load_tiles(name, tile_width, tile_height, tileable = true)
click to toggle source
# File lib/shirokuro/content/content_manager.rb, line 27 def load_tiles(name, tile_width, tile_height, tileable = true) asset_name = "#{@content_root}#{name}" unless @cache[asset_name] == nil return @cache[asset_name] end @cache[asset_name] = Gosu::Image.load_tiles(@window, asset_name, tile_width, tile_height, tileable) if @nearest_filtering @cache[asset_name].each{ |image| image.retro! } end return load_tiles(name, tile_width, tile_height) end