GDevelop Core
Core library for developing platforms and tools compatible with GDevelop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Public Member Functions | Public Attributes | List of all members
Polygon2d Class Reference

Represents a polygon. Usually used for collisions masks. More...

#include <Polygon2d.h>

Public Member Functions

std::vector< sf::Vector2f > & GetVertices ()
 Get the vertices composing the polygon.
 
const std::vector< sf::Vector2f > & GetVertices () const
 Get the vertices composing the polygon.
 
void Move (float x, float y)
 Moves each vertices from the given amount. More...
 
void Rotate (float angle)
 Rotate the polygon. More...
 
void ComputeEdges () const
 Automatically fill edges vector using vertices.
 
bool IsConvex () const
 Check if the polygon is convex. More...
 
sf::Vector2f ComputeCenter () const
 Return the position of the center of the polygon.
 

Static Public Member Functions

Tools

Tool functions

static Polygon2d CreateRectangle (float width, float height)
 Create a rectangle.
 

Public Attributes

std::vector< sf::Vector2f > vertices
 The vertices composing the polygon.
 
std::vector< sf::Vector2f > edges
 Edges. Can be computed from vertices using ComputeEdges()
 

Detailed Description

Represents a polygon. Usually used for collisions masks.

This class stores the vertices of the polygon. It can also compute and store the edges ( needed by some collisions algorithms ) if ComputeEdges is called.

Member Function Documentation

bool Polygon2d::IsConvex ( ) const

Check if the polygon is convex.

Returns
true if the polygon is convex
void Polygon2d::Move ( float  x,
float  y 
)

Moves each vertices from the given amount.

Note
Edges are updated, there is no need to call ComputeEdges after calling Move.
void Polygon2d::Rotate ( float  angle)

Rotate the polygon.

Parameters
angleAngle in radians
Warning
Rotation is made clockwise
edges vector is not updated, you have to call ComputeEdges if needed.

The documentation for this class was generated from the following files: