Class: SlideField::ObjectManager::Rect

Inherits:
Base
  • Object
show all
Defined in:
lib/slidefield/objects/rect.rb

Instance Method Summary collapse

Methods inherited from Base

#execute, #initialize, #method_missing, #on_activate, #on_deactivate, #on_unload

Constructor Details

This class inherits a constructor from SlideField::ObjectManager::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class SlideField::ObjectManager::Base

Instance Method Details

#on_draw(animator) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/slidefield/objects/rect.rb', line 22

def on_draw(animator)
  tr = animator.transform @obj
  return if tr.skip_draw?

  x = @x + tr.x_offset
  y = @y + tr.y_offset

  width = @width * tr.scale
  height = @height * tr.scale

  color = @fill.dup
  color.alpha = tr.opacity * @fill.alpha

  @window.draw_quad(
    x, y, color,
    width + x, y, color,
    x, height + y, color,
    width + x, height + y, color,
    @z
  )
end

#on_loadObject



14
15
16
17
18
19
20
# File 'lib/slidefield/objects/rect.rb', line 14

def on_load
  @x, @y = @obj.get :position
  @z = @obj.get :z_order

  @width, @height = @obj.get :size
  @fill = Gosu::Color.rgba *@obj.get(:fill)
end