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 | List of all members
gd::Sprite Class Reference

Represents a sprite to be displayed on the screen. More...

#include <Sprite.h>

Public Member Functions

void SetImageName (const gd::String &image_)
 Change the name of the sprite image.
 
const gd::StringGetImageName () const
 Get the name of the sprite image.
 
gd::StringGetImageName ()
 Get the name of the sprite image.
 
std::vector< Polygon2dGetCollisionMask () const
 Get the collision mask (custom or automatically generated owing to IsCollisionMaskAutomatic()) More...
 
std::vector< Polygon2d > & GetCustomCollisionMask ()
 Get the custom collision mask.
 
const std::vector< Polygon2d > & GetCustomCollisionMask () const
 Get the custom collision mask.
 
void SetCustomCollisionMask (const std::vector< Polygon2d > &collisionMask)
 Set the custom collision mask. Call then SetCollisionMaskAutomatic(false) to use it.
 
bool IsCollisionMaskAutomatic () const
 Return true if the collision mask is a bounding box, false if a custom collision mask is used.
 
void SetCollisionMaskAutomatic (bool enabled)
 Un/set use of the custom collision mask.
 
std::vector< Point > & GetAllNonDefaultPoints ()
 Return all points, excluding origin and center.
 
const std::vector< Point > & GetAllNonDefaultPoints () const
 Return all points, excluding origin and center.
 
void AddPoint (const Point &point)
 Add a point.
 
void DelPoint (const gd::String &name)
 Delete a point.
 
const PointGetPoint (const gd::String &name) const
 Get the specified point.
 
PointGetPoint (const gd::String &name)
 Get the specified point.
 
bool HasPoint (const gd::String &name) const
 Return true if the point exists.
 
const PointGetOrigin () const
 Return Origin point.
 
PointGetOrigin ()
 Return Origin point.
 
const PointGetCenter () const
 Return Center point. More...
 
PointGetCenter ()
 Return Center point. More...
 
bool IsDefaultCenterPoint () const
 Return true if the center point is automatically computed.
 
bool SetDefaultCenterPoint (bool enabled)
 Un/set center as being automatically computed.
 
Sprite runtime management

Functions used by the C++ game engine.

const sf::Sprite & GetSFMLSprite () const
 Get the SFML sprite associated with the sprite.
 
sf::Sprite & GetSFMLSprite ()
 Get the SFML sprite associated with the sprite.
 
void LoadImage (std::shared_ptr< SFMLTextureWrapper > image)
 Set the SFML texture of the sprite.
 
std::shared_ptr
< SFMLTextureWrapper
GetSFMLTexture ()
 Get SFML texture used by the sprite.
 
const std::shared_ptr
< SFMLTextureWrapper
GetSFMLTexture () const
 Get SFML texture used by the sprite.
 
void MakeSpriteOwnsItsImage ()
 Make the sprite, if it uses a texture from ImageManager, copy this texture and take ownership of it.
 

Detailed Description

Represents a sprite to be displayed on the screen.

A sprite contains a SFML sprite to be displayed, some points, and can also have its own texture (rather than a texture from ImageManager).

See also
Direction
SpriteObject

Member Function Documentation

const Point& gd::Sprite::GetCenter ( ) const
inline

Return Center point.

Warning
If the image has not been loaded (using LoadImage) and the center point is set as automatic, the returned point won't be correct.
Point& gd::Sprite::GetCenter ( )
inline

Return Center point.

Warning
If the image has not been loaded (using LoadImage) and the center point is set as automatic, the returned point won't be correct.
std::vector< Polygon2d > gd::Sprite::GetCollisionMask ( ) const

Get the collision mask (custom or automatically generated owing to IsCollisionMaskAutomatic())

Warning
If the image has not been loaded ( using LoadImage ) and the collision mask is set as automatic, the returned mask won't be correct.

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