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?, #touch_enabled?

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, #run_action, #stop_action, #stop_all_actions

Constructor Details

#initialize(title = '') ⇒ Button

Creates a new Button widget with an optional title.

Parameters:

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

    title for the button.



1225
# File 'motion-game', line 1225

def initialize(title=''); end

Instance Attribute Details

#fontString

Returns name of the font used for the button title.

Returns:

  • (String)

    name of the font used for the button title.



1237
1238
1239
# File 'motion-game', line 1237

def font
  @font
end

#font_sizeInteger

Returns size of the font used by for button title.

Returns:

  • (Integer)

    size of the font used by for button title.



1240
1241
1242
# File 'motion-game', line 1240

def font_size
  @font_size
end

#textString

Returns title of the button.

Returns:

  • (String)

    title of the button.



1231
1232
1233
# File 'motion-game', line 1231

def text
  @text
end

#text_colorColor

Returns color of the title.

Returns:

  • (Color)

    color of the title.



1234
1235
1236
# File 'motion-game', line 1234

def text_color
  @text_color
end

#zoom_scaleFloat

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.



1244
1245
1246
# File 'motion-game', line 1244

def zoom_scale
  @zoom_scale
end