Class: MG::Button

Inherits:
Widget show all
Defined in:
doc/API_reference.rb

Overview

button.on_touch { |type| puts “touched!” if type == :end }

Instance Attribute Summary collapse

Attributes inherited from Node

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

Constructors collapse

Instance Method Summary collapse

Methods inherited from Widget

#enabled=, #enabled?, #highlighted=, #highlighted?, #on_touch, #touch_enabled=, #touch_enabled?

Methods inherited from Node

#add, #children, #clear, #delete, #delete_from_parent, #intersects?, #number_of_running_actions, #parent, #run_action, #schedule, #schedule_once, #stop_action, #stop_all_actions, #unschedule, #visible=, #visible?

Constructor Details

#initialize(title = '', font = '', font_size = 0) ⇒ Button

Creates a new Button widget with an optional title.

Parameters:

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

    title for the button.

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

    name of the font the button widget should use.

  • font_size (Integer) (defaults to: 0)

    size of the font the button widget should use.



1433
# File 'doc/API_reference.rb', line 1433

def initialize(title='', font='', font_size=0); 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.



1445
1446
1447
# File 'doc/API_reference.rb', line 1445

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.



1448
1449
1450
# File 'doc/API_reference.rb', line 1448

def font_size
  @font_size
end

#textString

Returns title of the button.

Returns:

  • (String)

    title of the button.



1439
1440
1441
# File 'doc/API_reference.rb', line 1439

def text
  @text
end

#text_colorColor

Returns color of the title.

Returns:

  • (Color)

    color of the title.



1442
1443
1444
# File 'doc/API_reference.rb', line 1442

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.



1452
1453
1454
# File 'doc/API_reference.rb', line 1452

def zoom_scale
  @zoom_scale
end

Instance Method Details

#load_texture_disabled(name) ⇒ self

Load disabled state texture for button.

Parameters:

  • name (String)

    A texture name.

Returns:

  • (self)

    the receiver.



1467
# File 'doc/API_reference.rb', line 1467

def load_texture_disabled(name); end

#load_texture_normal(name) ⇒ self

Load normal state texture for button.

Parameters:

  • name (String)

    A texture name.

Returns:

  • (self)

    the receiver.



1457
# File 'doc/API_reference.rb', line 1457

def load_texture_normal(name); end

#load_texture_pressed(name) ⇒ self

Load selected state texture for button.

Parameters:

  • name (String)

    A texture name.

Returns:

  • (self)

    the receiver.



1462
# File 'doc/API_reference.rb', line 1462

def load_texture_pressed(name); end