Class Path
Parent: Sprite
A path is a usually invisible line objects in the level (e.g. platforms) follow. While the movement could usually be achieved with pure scripting using timers, paths are implemented purely in C++ and as such perform better. On the other hands, paths are limited to a defined number of movements, while scripting your movement allows all kinds of crazy things to be done.
Class Methods
new
new() → a_path
Creates a new path with the default values.
Instance Methods
add_segment
add_segment( segment )
Adds the given segment to the end of the path.
Parameters
- segment
-
The Path::Segment instance to add to the path.
each_segment
each_segment(){|segment| ...}
Iterates over all segments in the path and yields them into the given block one-by-one.
Parameters
- segment (**block**)
-
The currently iterated path segment. A Path::Segment instance.
identifier
identifier() → a_string or nil
Returns the path’s current identifier as a string. If no identifier has been set, returns nil.
identifier=
identifier=( str ) → str
Specify this path’s identifier.
Parameters
- str
The path’s new identifier.
rewind=
rewind=( bool ) → bool
Specify whether or not to rewind when the object moving along the path reached the paths end. The default is not to rewind, i.e. to mirror and move the path backwards.
Parameters
- bool
Whether or not to rewind.
rewind?
rewind?() → true or false
Returns true or false depending on whether this path mirrors (false) or rewinds (true).
segments
segments() → an_array
Returns all segments of this path as an array.
Return value
An array of Path::Segment instances.
show_line=
show_line=( bool ) → bool
Specify whether or not the path should have its moving line drawn (not to draw is the default). This feature is EXPERIMENTAL and usually does not work as expected.
Parameters
- bool
Whether or not to draw the line.
show_line?
show_line?() → true or false
Returns true or false depending on whether the path’s movement line should be drawn.