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.



1202
# File 'motion-game', line 1202

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.



1214
1215
1216
# File 'motion-game', line 1214

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.



1217
1218
1219
# File 'motion-game', line 1217

def font_size
  @font_size
end

#textString

Returns title of the button.

Returns:

  • (String)

    title of the button.



1208
1209
1210
# File 'motion-game', line 1208

def text
  @text
end

#text_colorColor

Returns color of the title.

Returns:

  • (Color)

    color of the title.



1211
1212
1213
# File 'motion-game', line 1211

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.



1221
1222
1223
# File 'motion-game', line 1221

def zoom_scale
  @zoom_scale
end