Class: MG::Node
- Inherits:
-
Object
- Object
- MG::Node
- Defined in:
- motion-game
Overview
Node is the base class of objects in the scene graph. You should not instantiate this class directly but use a subclass instead.
Properties (collapse)
-
- (Float) alpha
The opacity (alpha) level of the node, as a Float from the
0.0
to1.0
range. -
- (Point) anchor_point
The anchor point of the node, as a set of percentage coordinates.
-
- (Color) color
The color of the node.
-
- (String) name
A name to easily identify the node in the graph.
-
- (Point) position
The [x, y] position of the node in its parent's coordinate system.
-
- (Float) rotation
Returns the rotation of the node in degrees.
-
- (Float) scale
Returns the scaling factor of the node, which multiplies its width, height and depth.
-
- (Size) size
The content size of the node.
-
- (Boolean) visible?
Whether the node should be visible.
-
- (Integer) z_index
The local z-order index of the receiver in the scene graph, which will determine its priority when rendering the scene.
Miscellaneous (collapse)
-
- (Boolean) intersects?(node)
Whether the receiver's bounding box intersects with the given node's bounding box.
Container (collapse)
-
- (Node) add(node, zpos = 0)
Adds a child node to the receiver with a local z-order.
-
- (Array<Node>) children
An array of
Node
objects that have been added to the receiver. -
- (Node) clear(cleanup = true)
Removes all children nodes from the receiver.
-
- (Node) delete(node, cleanup = true)
Removes the given child node from the receiver.
-
- (Node) delete_from_parent(cleanup = true)
Removes the receiver node from its parent.
-
- (Node) parent
The parent node, or
nil
if there isn't one.
Instance Attribute Details
- (Float) alpha
Returns the opacity (alpha) level of the node, as a Float from the
0.0
to 1.0
range.
281 282 283 |
# File 'motion-game', line 281 def alpha @alpha end |
- (Point) anchor_point
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.
266 267 268 |
# File 'motion-game', line 266 def anchor_point @anchor_point end |
- (Color) color
Returns the color of the node.
288 289 290 |
# File 'motion-game', line 288 def color @color end |
- (String) name
Returns a name to easily identify the node in the graph.
302 303 304 |
# File 'motion-game', line 302 def name @name end |
- (Point) position
Returns the [x, y] position of the node in its parent's coordinate system.
270 271 272 |
# File 'motion-game', line 270 def position @position end |
- (Float) rotation
Returns the rotation of the node in degrees. 0 is the default angle. Positive values rotate node clockwise, and negative values for anti-clockwise
294 295 296 |
# File 'motion-game', line 294 def rotation @rotation end |
- (Float) scale
Returns the scaling factor of the node, which multiplies its width, height and depth.
299 300 301 |
# File 'motion-game', line 299 def scale @scale end |
- (Size) size
Returns the content size of the node.
273 274 275 |
# File 'motion-game', line 273 def size @size end |
- (Boolean) visible?
Returns whether the node should be visible. The default value is true.
277 278 279 |
# File 'motion-game', line 277
def visible?
@visible?
end
|
- (Integer) z_index
Returns the local z-order index of the receiver in the scene graph, which will determine its priority when rendering the scene.
285 286 287 |
# File 'motion-game', line 285 def z_index @z_index end |
Instance Method Details
- (Node) add(node, zpos = 0)
Adds a child node to the receiver with a local z-order.
319 |
# File 'motion-game', line 319 def add(node, zpos=0); end |
- (Array<Node>) children
Returns an array of Node
objects that have been added to the
receiver.
338 |
# File 'motion-game', line 338 def children; end |
- (Node) clear(cleanup = true)
Removes all children nodes from the receiver.
325 |
# File 'motion-game', line 325 def clear(cleanup=true); end |
- (Node) delete(node, cleanup = true)
Removes the given child node from the receiver.
331 |
# File 'motion-game', line 331 def delete(node, cleanup=true); end |
- (Node) delete_from_parent(cleanup = true)
Removes the receiver node from its parent. Same as:
node.parent.delete(node, cleanup)
346 |
# File 'motion-game', line 346 def delete_from_parent(cleanup=true); end |
- (Boolean) intersects?(node)
Returns whether the receiver's bounding box intersects with the given node's bounding box.
310 |
# File 'motion-game', line 310 def intersects?(node); end |
- (Node) parent
Returns the parent node, or nil
if there isn't one.
334 |
# File 'motion-game', line 334 def parent; end |