Class: MG::Button

Inherits:
Widget show all
Defined in:
motion-game

Overview

A button widget. The Widget#on_touch method can be used to set a callback when the button is activated. Example:

button = Button.new("Touch me!")
button.on_touch { |type| puts "touched!" if type == :end }

Properties (collapse)

Attributes inherited from Widget

#enabled?, #highlighted?

Attributes inherited from Node

#alpha, #anchor_point, #color, #name, #position, #rotation, #scale, #size, #visible?, #z_index

Constructors (collapse)

Methods inherited from Widget

#on_touch

Methods inherited from Node

#add, #children, #clear, #delete, #delete_from_parent, #intersects?, #parent

Constructor Details

- (Button) initialize(title = '')

Creates a new Button widget with an optional title.

Parameters:

  • title (String) (defaults to: '')

    title for the button.



744
# File 'motion-game', line 744

def initialize(title=''); end

Instance Attribute Details

- (String) font

Returns name of the font used for the button title.

Returns:

  • (String)

    name of the font used for the button title.



756
757
758
# File 'motion-game', line 756

def font
  @font
end

- (Integer) font_size

Returns size of the font used by for button title.

Returns:

  • (Integer)

    size of the font used by for button title.



759
760
761
# File 'motion-game', line 759

def font_size
  @font_size
end

- (String) text

Returns title of the button.

Returns:

  • (String)

    title of the button.



750
751
752
# File 'motion-game', line 750

def text
  @text
end

- (Color) text_color

Returns color of the title.

Returns:

  • (Color)

    color of the title.



753
754
755
# File 'motion-game', line 753

def text_color
  @text_color
end

- (Float) zoom_scale

Returns the value with which the button will zoom when the user presses it.

Returns:

  • (Float)

    the value with which the button will zoom when the user presses it.



763
764
765
# File 'motion-game', line 763

def zoom_scale
  @zoom_scale
end