NavigationPolygon¶
Inherits: Resource < Reference < Object
Un nodo que tiene métodos para dibujar contornos o usar índices de vértices para crear polígonos de navegación.
Descripción¶
There are two ways to create polygons. Either by using the add_outline method, or using the add_polygon method.
Using add_outline:
var polygon = NavigationPolygon.new()
var outline = PoolVector2Array([Vector2(0, 0), Vector2(0, 50), Vector2(50, 50), Vector2(50, 0)])
polygon.add_outline(outline)
polygon.make_polygons_from_outlines()
$NavigationPolygonInstance.navpoly = polygon
Using add_polygon and indices of the vertices array.
var polygon = NavigationPolygon.new()
var vertices = PoolVector2Array([Vector2(0, 0), Vector2(0, 50), Vector2(50, 50), Vector2(50, 0)])
polygon.set_vertices(vertices)
var indices = PoolIntArray([0, 1, 2, 3])
polygon.add_polygon(indices)
$NavigationPolygonInstance.navpoly = polygon
Tutoriales¶
Métodos¶
void |
add_outline ( PoolVector2Array outline ) |
void |
add_outline_at_index ( PoolVector2Array outline, int index ) |
void |
add_polygon ( PoolIntArray polygon ) |
void |
clear_outlines ( ) |
void |
clear_polygons ( ) |
get_outline ( int idx ) const |
|
get_outline_count ( ) const |
|
get_polygon ( int idx ) |
|
get_polygon_count ( ) const |
|
get_vertices ( ) const |
|
void |
|
void |
remove_outline ( int idx ) |
void |
set_outline ( int idx, PoolVector2Array outline ) |
void |
set_vertices ( PoolVector2Array vertices ) |
Descripciones de Métodos¶
void add_outline ( PoolVector2Array outline )
Appends a PoolVector2Array that contains the vertices of an outline to the internal array that contains all the outlines. You have to call make_polygons_from_outlines in order for this array to be converted to polygons that the engine will use.
void add_outline_at_index ( PoolVector2Array outline, int index )
Adds a PoolVector2Array that contains the vertices of an outline to the internal array that contains all the outlines at a fixed position. You have to call make_polygons_from_outlines in order for this array to be converted to polygons that the engine will use.
void add_polygon ( PoolIntArray polygon )
Añade un polígono usando los índices de los vértices que obtienes al llamar a get_vertices.
void clear_outlines ( )
Limpia el array de los contornos, pero no limpia los vértices y los polígonos que fueron creados por ellos.
void clear_polygons ( )
Limpia el array de polígonos, pero no limpia el array de contornos y vértices.
PoolVector2Array get_outline ( int idx ) const
Returns a PoolVector2Array containing the vertices of an outline that was created in the editor or by script.
int get_outline_count ( ) const
Devuelve el número de contornos que fueron creados en el editor o por el script.
PoolIntArray get_polygon ( int idx )
Returns a PoolIntArray containing the indices of the vertices of a created polygon.
int get_polygon_count ( ) const
Devuelve el recuento de todos los polígonos.
PoolVector2Array get_vertices ( ) const
Returns a PoolVector2Array containing all the vertices being used to create the polygons.
void make_polygons_from_outlines ( )
Crea polígonos a partir de los contornos añadidos en el editor o por el script.
void remove_outline ( int idx )
Elimina un esquema creado en el editor o por el guión. Tienes que llamar a make_polygons_from_outlines para que los polígonos se actualicen.
void set_outline ( int idx, PoolVector2Array outline )
Cambia un contorno creado en el editor o por el script. Tienes que llamar a make_polygons_from_outlines para que los polígonos se actualicen.
void set_vertices ( PoolVector2Array vertices )
Establece los vértices que pueden ser indexados para crear polígonos con el método add_polygon.