Class: AGL::Effect
Instance Attribute Summary
Attributes inherited from Sprite
#img_index, #x, #y
Instance Method Summary collapse
-
#initialize(x, y, life_time, img, sprite_cols = nil, sprite_rows = nil, indices = nil, interval = 1) ⇒ Effect
constructor
A new instance of Effect.
- #update ⇒ Object
Methods inherited from Sprite
Constructor Details
#initialize(x, y, life_time, img, sprite_cols = nil, sprite_rows = nil, indices = nil, interval = 1) ⇒ Effect
Returns a new instance of Effect.
95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/minigl/game_object.rb', line 95 def initialize x, y, life_time, img, sprite_cols = nil, sprite_rows = nil, indices = nil, interval = 1 super x, y, img, sprite_cols, sprite_rows @life_time = life_time @timer = 0 if indices @indices = indices else @indices = *(0..(@img.length - 1)) end @interval = interval end |
Instance Method Details
#update ⇒ Object
107 108 109 110 111 112 113 |
# File 'lib/minigl/game_object.rb', line 107 def update animate @indices, @interval @timer += 1 if @timer == @life_time @dead = true end end |