Method: MiniGL::Res.imgs
- Defined in:
- lib/minigl/global.rb
.imgs(id, sprite_cols, sprite_rows, global = false, ext = '.png', retro = nil, tileable = false) ⇒ Object
Returns an array of Gosu::Image
objects, using the image as a spritesheet. The image with index 0 will be the top left sprite, and the following indices raise first from left to right and then from top to bottom.
Parameters:
- id
-
A string or symbol representing the path to the image. See
img
for details. - sprite_cols
-
Number of columns in the spritesheet.
- sprite_rows
-
Number of rows in the spritesheet.
- global
-
Set to true if you want to keep the image in memory until the game execution is finished. If false, the image will be released when you call
clear
. - ext
-
The extension of the file being loaded. Specify only if it is other than “.png”.
- retro
-
Whether the image should be loaded with the ‘retro’ option set (see
Gosu::Image
for details). If the value is omitted, theRes.retro_images
value will be used.
636 637 638 639 640 641 642 643 |
# File 'lib/minigl/global.rb', line 636 def imgs(id, sprite_cols, sprite_rows, global = false, ext = '.png', retro = nil, tileable = false) a = global ? @global_imgs : @imgs return a[id] if a[id] s = @prefix + @img_dir + id.to_s.split(@separator).join('/') + ext retro = Res.retro_images if retro.nil? imgs = Gosu::Image.load_tiles s, -sprite_cols, -sprite_rows, tileable: tileable, retro: retro a[id] = imgs end |