class Core::GUI::ImageButton

Same as Button, but draws an image instead of text

Attributes

bg[R]

Public Class Methods

new(x, y, file, proc, w=-1, h=-1) click to toggle source
Calls superclass method Core::GUI::Button::new
# File lib/gui/button.rb, line 72
def initialize(x, y, file, proc, w=-1, h=-1)
  @bg = Core.sprite(file.to_s)
  if w < 0
    @w = w = @bg.width
  end
  if h < 0
    @h = h = @bg.height
  end
  super(x, y, w, h, "", proc, false)
end

Public Instance Methods

draw() click to toggle source
# File lib/gui/button.rb, line 82
def draw
  color = Gosu::Color.new(255, 255, 255, 255)
  if !@enabled
    color.saturation = 125
  end
  @bg.draw(@x+@xoff, @y+@yoff, Core::GUI_Z + 10 + @zoff, @w/@bg.width.to_f, @h/@bg.height.to_f, color)
  if @selected and @enabled
    @hi.draw(@x+@xoff, @y+@yoff, Core::GUI_Z + 11 + @zoff, @w/@hi.width.to_f, @h/@hi.height.to_f, 0xff999999, :additive)
  end
end