El Octavio
1.0
This is a video game about adventures.
|
Specialized shape representing a convex polygon. More...
#include <ConvexShape.hpp>
Public Member Functions | |
ConvexShape (std::size_t pointCount=0) | |
Default constructor. More... | |
void | setPointCount (std::size_t count) |
Set the number of points of the polygon. More... | |
virtual std::size_t | getPointCount () const |
Get the number of points of the polygon. More... | |
void | setPoint (std::size_t index, const Vector2f &point) |
Set the position of a point. More... | |
virtual Vector2f | getPoint (std::size_t index) const |
Get the position of a point. More... | |
![]() | |
virtual | ~Shape () |
Virtual destructor. More... | |
void | setTexture (const Texture *texture, bool resetRect=false) |
Change the source texture of the shape. More... | |
void | setTextureRect (const IntRect &rect) |
Set the sub-rectangle of the texture that the shape will display. More... | |
void | setFillColor (const Color &color) |
Set the fill color of the shape. More... | |
void | setOutlineColor (const Color &color) |
Set the outline color of the shape. More... | |
void | setOutlineThickness (float thickness) |
Set the thickness of the shape's outline. More... | |
const Texture * | getTexture () const |
Get the source texture of the shape. More... | |
const IntRect & | getTextureRect () const |
Get the sub-rectangle of the texture displayed by the shape. More... | |
const Color & | getFillColor () const |
Get the fill color of the shape. More... | |
const Color & | getOutlineColor () const |
Get the outline color of the shape. More... | |
float | getOutlineThickness () const |
Get the outline thickness of the shape. More... | |
virtual std::size_t | getPointCount () const =0 |
Get the total number of points of the shape. More... | |
virtual Vector2f | getPoint (std::size_t index) const =0 |
Get a point of the shape. More... | |
FloatRect | getLocalBounds () const |
Get the local bounding rectangle of the entity. More... | |
FloatRect | getGlobalBounds () const |
Get the global (non-minimal) bounding rectangle of the entity. More... | |
![]() | |
virtual | ~Drawable () |
Virtual destructor. More... | |
![]() | |
Transformable () | |
Default constructor. More... | |
virtual | ~Transformable () |
Virtual destructor. More... | |
void | setPosition (float x, float y) |
set the position of the object More... | |
void | setPosition (const Vector2f &position) |
set the position of the object More... | |
void | setRotation (float angle) |
set the orientation of the object More... | |
void | setScale (float factorX, float factorY) |
set the scale factors of the object More... | |
void | setScale (const Vector2f &factors) |
set the scale factors of the object More... | |
void | setOrigin (float x, float y) |
set the local origin of the object More... | |
void | setOrigin (const Vector2f &origin) |
set the local origin of the object More... | |
const Vector2f & | getPosition () const |
get the position of the object More... | |
float | getRotation () const |
get the orientation of the object More... | |
const Vector2f & | getScale () const |
get the current scale of the object More... | |
const Vector2f & | getOrigin () const |
get the local origin of the object More... | |
void | move (float offsetX, float offsetY) |
Move the object by a given offset. More... | |
void | move (const Vector2f &offset) |
Move the object by a given offset. More... | |
void | rotate (float angle) |
Rotate the object. More... | |
void | scale (float factorX, float factorY) |
Scale the object. More... | |
void | scale (const Vector2f &factor) |
Scale the object. More... | |
const Transform & | getTransform () const |
get the combined transform of the object More... | |
const Transform & | getInverseTransform () const |
get the inverse of the combined transform of the object More... | |
Additional Inherited Members | |
![]() | |
Shape () | |
Default constructor. More... | |
void | update () |
Recompute the internal geometry of the shape. More... | |
virtual void | draw (RenderTarget &target, RenderStates states) const =0 |
Draw the object to a render target. More... | |
Specialized shape representing a convex polygon.
This class inherits all the functions of sf::Transformable (position, rotation, scale, bounds, ...) as well as the functions of sf::Shape (outline, color, texture, ...).
It is important to keep in mind that a convex shape must always be... convex, otherwise it may not be drawn correctly. Moreover, the points must be defined in order; using a random order would result in an incorrect shape.
Usage example:
Definition at line 42 of file ConvexShape.hpp.
|
explicit |
Default constructor.
pointCount | Number of points of the polygon |
|
virtual |
Get the position of a point.
The returned point is in local coordinates, that is, the shape's transforms (position, rotation, scale) are not taken into account. The result is undefined if index is out of the valid range.
index | Index of the point to get, in range [0 .. getPointCount() - 1] |
Implements sf::Shape.
|
virtual |
Get the number of points of the polygon.
Implements sf::Shape.
void sf::ConvexShape::setPoint | ( | std::size_t | index, |
const Vector2f & | point | ||
) |
Set the position of a point.
Don't forget that the polygon must remain convex, and the points need to stay ordered! setPointCount must be called first in order to set the total number of points. The result is undefined if index is out of the valid range.
index | Index of the point to change, in range [0 .. getPointCount() - 1] |
point | New position of the point |
void sf::ConvexShape::setPointCount | ( | std::size_t | count | ) |
Set the number of points of the polygon.
count must be greater than 2 to define a valid shape.
count | New number of points of the polygon |