Class: Okami::Image
- Inherits:
-
Gosu::Image
- Object
- Gosu::Image
- Okami::Image
- Includes:
- DrawMethods
- Defined in:
- lib/okami/image.rb
Class Attribute Summary collapse
-
.load_path ⇒ Object
The directory to load the images from.
-
.tileable ⇒ Object
Default value for wether the images should be tileable or not.
Class Method Summary collapse
-
.load(relative_path, options = nil) ⇒ Object
Character::Will load and cache even if it’s already cached.
-
.load_tiles(relative_path, tile_width, tile_height, tileable = @tileable) ⇒ Object
Character::Will load and cache even if it’s already cached.
- .new_by_options(options) ⇒ Object
-
.require(relative_path, options = nil) ⇒ Object
(also: [])
Character::Will cache the images so they’re only loaded once.
- .require_tiles(relative_path, tile_width = nil, tile_height = nil, tileable = @tileable) ⇒ Object
Methods included from DrawMethods
Class Attribute Details
.load_path ⇒ Object
The directory to load the images from
32 33 34 |
# File 'lib/okami/image.rb', line 32 def load_path @load_path end |
.tileable ⇒ Object
Default value for wether the images should be tileable or not
30 31 32 |
# File 'lib/okami/image.rb', line 30 def tileable @tileable end |
Class Method Details
.load(relative_path, options = nil) ⇒ Object
Character::Will load and cache even if it’s already cached
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/okami/image.rb', line 51 def load relative_path, =nil image_path = File.join(@load_path, relative_path) Okami::ImageCache[relative_path] = if else new $window, image_path end end |
.load_tiles(relative_path, tile_width, tile_height, tileable = @tileable) ⇒ Object
Character::Will load and cache even if it’s already cached
77 78 79 80 81 82 83 84 85 86 |
# File 'lib/okami/image.rb', line 77 def load_tiles relative_path, tile_width, tile_height, tileable=@tileable image_path = File.join(@load_path, relative_path) tiles = super $window, image_path, tile_width, tile_height, tileable tiles.each { |tile| tile.extend Okami::DrawMethods } Okami::ImageTileCache[relative_path] = tiles end |
.new_by_options(options) ⇒ Object
62 63 64 65 66 |
# File 'lib/okami/image.rb', line 62 def tileable = [:tileable] || @tileable src_rect = [:src_rect] new $window, image_path, tileable, *src_rect end |
.require(relative_path, options = nil) ⇒ Object Also known as: []
Character::Will cache the images so they’re only loaded once.
44 45 46 47 |
# File 'lib/okami/image.rb', line 44 def require relative_path, =nil Okami::ImageCache[relative_path] || load(relative_path, ) end |
.require_tiles(relative_path, tile_width = nil, tile_height = nil, tileable = @tileable) ⇒ Object
68 69 70 71 72 73 74 |
# File 'lib/okami/image.rb', line 68 def require_tiles relative_path, tile_width=nil, tile_height=nil, tileable=@tileable Okami::ImageTileCache[relative_path] || load_tiles(relative_path, tile_width, tile_height, tileable) end |