Class: MG::Node

Inherits:
Object
  • Object
show all
Defined in:
doc/API_reference.rb

Overview

instantiate this class directly but use a subclass instead.

Direct Known Subclasses

Draw, Parallax, Particle, Scene, Sprite, Widget

Instance Attribute Summary collapse

Container collapse

Instance Method Summary collapse

Instance Attribute Details

#alphaFloat

Returns the opacity (alpha) level of the node, as a Float from the 0.0 to 1.0 range.

Returns:

  • (Float)

    the opacity (alpha) level of the node, as a Float from the 0.0 to 1.0 range.



719
720
721
# File 'doc/API_reference.rb', line 719

def alpha
  @alpha
end

#anchor_pointPoint

The anchor point of the node, as a set of percentage coordinates. The anchor point represents where the node will be attached to its parent, and is normalized as a percentage. [0, 0] means the bottom-left corner, and [1, 1] the top-right corner. You can also use values lower than 0 and higher than 1. The default anchor point value is [0.5, 0.5], which means the center of the parent.

Returns:

  • (Point)

    the anchor point of the node.



700
701
702
# File 'doc/API_reference.rb', line 700

def anchor_point
  @anchor_point
end

#colorColor

Returns the color of the node.

Returns:

  • (Color)

    the color of the node.



726
727
728
# File 'doc/API_reference.rb', line 726

def color
  @color
end

#nameString

Returns a name to easily identify the node in the graph.

Returns:

  • (String)

    a name to easily identify the node in the graph.



740
741
742
# File 'doc/API_reference.rb', line 740

def name
  @name
end

#positionPoint

Returns the [x, y] position of the node in its parent’s coordinate system.

Returns:

  • (Point)

    the [x, y] position of the node in its parent’s coordinate system.



704
705
706
# File 'doc/API_reference.rb', line 704

def position
  @position
end

#rotationFloat

Returns the rotation of the node in degrees. 0 is the default angle. Positive values rotate node clockwise, and negative values for anti-clockwise

Returns:

  • (Float)

    the rotation of the node in degrees.



732
733
734
# File 'doc/API_reference.rb', line 732

def rotation
  @rotation
end

#scaleFloat

Returns the scaling factor of the node, which multiplies its width, height and depth.

Returns:

  • (Float)

    the scaling factor.



737
738
739
# File 'doc/API_reference.rb', line 737

def scale
  @scale
end

#sizeSize

Returns the content size of the node.

Returns:

  • (Size)

    the content size of the node.



707
708
709
# File 'doc/API_reference.rb', line 707

def size
  @size
end

#z_indexInteger

Returns the local z-order index of the receiver in the scene graph, which will determine its priority when rendering the scene.

Returns:

  • (Integer)

    the local z-order index of the receiver in the scene graph, which will determine its priority when rendering the scene.



723
724
725
# File 'doc/API_reference.rb', line 723

def z_index
  @z_index
end

Instance Method Details

#add(node, zpos = 0) ⇒ self

Adds a child node to the receiver with a local z-order.

Parameters:

  • node (Node)

    the child to add.

  • zpos (Integer) (defaults to: 0)

    the local z-order.

Returns:

  • (self)

    the receiver.



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

def add(node, zpos=0); end

#childrenArray<Node>

Returns an array of Node objects that have been added to the receiver.

Returns:

  • (Array<Node>)

    an array of Node objects that have been added to the receiver.



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

def children; end

#clear(cleanup = true) ⇒ self

Removes all children nodes from the receiver.

Parameters:

  • cleanup (Boolean) (defaults to: true)

    cleans all running actions on children before removing them.

Returns:

  • (self)

    the receiver.



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

def clear(cleanup=true); end

#delete(node, cleanup = true) ⇒ self

Removes the given child node from the receiver.

Parameters:

  • cleanup (Boolean) (defaults to: true)

    cleans all running actions on child before removing it.

Returns:

  • (self)

    the receiver.



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

def delete(node, cleanup=true); end

#delete_from_parent(cleanup = true) ⇒ self

Removes the receiver node from its parent. Same as:

node.parent.delete(node, cleanup)

Parameters:

  • cleanup (Boolean) (defaults to: true)

    cleans all running actions on the receiver before removing it from the parent.

Returns:

  • (self)

    the receiver.



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

def delete_from_parent(cleanup=true); end

#intersects?(node) ⇒ Boolean

Returns whether the receiver’s bounding box intersects with the given node’s bounding box.

Parameters:

  • node (Node)

    a given Node object.

Returns:

  • (Boolean)

    whether the receiver’s bounding box intersects with the given node’s bounding box.



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

def intersects?(node); end

#number_of_running_actionsInteger

Returns the number of running actions for the node.

Returns:

  • (Integer)

    the number of running actions for the node.



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

def number_of_running_actions; end

#parentNode

Returns the parent node, or nil if there isn’t one.

Returns:

  • (Node)

    the parent node, or nil if there isn’t one.



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

def parent; end

#run_action(action) { ... } ⇒ self

Run the provided action on the receiver node.

Yields:

  • if passed a block, the block will be called for the action.

Returns:

  • (self)

    the receiver.



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

def run_action(action); end

#schedule(delay, repeat = 0, interval = 0) {|Float| ... } ⇒ String

Schedules a given block for execution.

Parameters:

  • delay (Float)

    the duration of the block, in seconds.

  • repeat (Integer) (defaults to: 0)

    the number of times the block should be repeated. If Repeat::FOREVER (or negative value directly) was given, the animation will loop forever.

  • interval (Float) (defaults to: 0)

    the interval between repetitions, in seconds.

Yields:

  • (Float)

    the given block will be yield with the delta value, in seconds.

Returns:

  • (String)

    a token representing the task that can be passed to #unschedule when needed.



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

def schedule(delay, repeat=0, interval=0); end

#schedule_once(delay) {|Float| ... } ⇒ String

Schedules a given block for execution that runs only once, with a delay of 0 or larger.

Parameters:

  • delay (Float)

    the duration of the block, in seconds.

Yields:

  • (Float)

    the given block will be yield with the delta value, in seconds.

Returns:

  • (String)

    a token representing the task that can be passed to #unschedule when needed.



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

def schedule_once(delay); end

#stop_action(action) ⇒ self

Stop the provided action

Parameters:

  • action (Action)

    the action to stop.

Returns:

  • (self)

    the receiver.



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

def stop_action(action); end

#stop_all_actionsself

Stop all actions running on the node

Returns:

  • (self)

    the receiver.



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

def stop_all_actions(); end

#unschedule(key) ⇒ self

Unschedules a task that’s currently running.

Parameters:

  • key (String)

    a token representing the task to unschedule, returned by #schedule.

Returns:

  • (self)

    the receiver.



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

def unschedule(key); end

#visible=(value) ⇒ Object

Set whether the node is visible.

Parameters:

  • value (Boolean)

    true if display the node.



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

def visible=(value); end

#visible?Boolean

Returns whether the node should be visible. The default value is true.

Returns:

  • (Boolean)

    whether the node should be visible. The default value is true.



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

def visible?; end