Method: AGL::Effect#initialize
- Defined in:
- lib/minigl/game_object.rb
#initialize(x, y, img, sprite_cols = nil, sprite_rows = nil, interval = 10, indices = nil, lifetime = nil) ⇒ Effect
Creates a new Effect.
Parameters:
- x
-
The x-coordinate in the screen (or map) where the effect will be drawn. This can be modified later via the
xattribute. - y
-
The y-coordinate in the screen (or map) where the effect will be drawn. This can be modified later via the
yattribute. - img
-
The image or spritesheet to use for this effect (see Sprite for details on spritesheets).
- sprite_cols
-
(see Sprite)
- sprite_rows
-
(see Sprite)
- interval
-
The interval between steps of the animation, in updates.
- indices
-
The indices to use in the animation. See Sprite#animate for details. If
nil, it will be the sequence from 0 tosprite_cols * sprite_rows - 1. - lifetime
-
The lifetime of the effect, in updates. After
updateis called this number of times, the effect will no longer be visible, even whendrawis called, and thedeadflag will be set totrue, so you get to know when to dispose of the Effect object. Ifnil, it will be set to@indices.length * interval, i.e., the exact time needed for one animation cycle to complete.
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 |
# File 'lib/minigl/game_object.rb', line 223 def initialize x, y, img, sprite_cols = nil, sprite_rows = nil, interval = 10, indices = nil, lifetime = nil super x, y, img, sprite_cols, sprite_rows @timer = 0 if indices @indices = indices else @indices = *(0..(@img.length - 1)) end @interval = interval if lifetime @lifetime = lifetime else @lifetime = @indices.length * interval end end |