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::SpriteObject Class Reference

Standard sprite object for extensions that implements the standard SpriteExtension (see gd::BuiltinExtensionsImplementer::ImplementsSpriteExtension). More...

#include <SpriteObject.h>

Inherits gd::Object.

Public Member Functions

 SpriteObject (gd::String name_)
 
std::unique_ptr< gd::ObjectClone () const override
 
void ExposeResources (gd::ArbitraryResourceWorker &worker) override
 Called ( e.g. during compilation ) so as to inventory internal resources and sometimes update their filename. Implementation example: More...
 
std::map< gd::String,
gd::PropertyDescriptor
GetProperties (gd::Project &project) const override
 Called when the IDE wants to know about the custom properties of the object. More...
 
bool UpdateProperty (const gd::String &name, const gd::String &value, gd::Project &project) override
 Called when the IDE wants to update a custom property of the object. More...
 
std::map< gd::String,
gd::PropertyDescriptor
GetInitialInstanceProperties (const gd::InitialInstance &position, gd::Project &project, gd::Layout &scene) override
 Called when the IDE wants to know about the custom properties of an initial instance of this object. More...
 
bool UpdateInitialInstanceProperty (gd::InitialInstance &position, const gd::String &name, const gd::String &value, gd::Project &project, gd::Layout &scene) override
 Called when the IDE wants to update a custom property of an initial instance of this object. More...
 
Animations

Methods related to animations management

const AnimationGetAnimation (std::size_t nb) const
 Return the animation at the specified index. If the index is out of bound, a "bad animation" object is returned.
 
AnimationGetAnimation (std::size_t nb)
 Return the animation at the specified index. If the index is out of bound, a "bad animation" object is returned.
 
std::size_t GetAnimationsCount () const
 Return the number of animations this object has.
 
void AddAnimation (const Animation &animation)
 Add an animation at the end of the existing ones.
 
bool RemoveAnimation (std::size_t nb)
 Remove an animation.
 
void RemoveAllAnimations ()
 Remove all animations.
 
bool HasNoAnimations () const
 Return true if the object hasn't any animation.
 
void SwapAnimations (std::size_t firstIndex, std::size_t secondIndex)
 Swap the position of two animations.
 
void MoveAnimation (std::size_t oldIndex, std::size_t newIndex)
 Change the position of the specified animation.
 
const std::vector< Animation > & GetAllAnimations () const
 Return a read-only reference to the vector containing all the animation of the object.
 
- Public Member Functions inherited from gd::Object
 Object (const gd::String &name)
 
 Object (const gd::Object &object)
 
Objectoperator= (const gd::Object &object)
 
virtual ~Object ()
 
void SetName (const gd::String &name_)
 Change the name of the object with the name passed as parameter.
 
const gd::StringGetName () const
 Return the name of the object.
 
void SetType (const gd::String &type_)
 Change the type of the object.
 
const gd::StringGetType () const
 Return the type of the object.
 
void SetTags (const gd::String &tags_)
 Change the tags of the object.
 
const gd::StringGetTags () const
 Return the tags of the object.
 
virtual bool SupportShaders ()
 
std::vector< gd::StringGetAllBehaviorNames () const
 Return a vector containing the names of all the behaviors used by the object.
 
BehaviorContentGetBehavior (const gd::String &name)
 Return a reference to the behavior called name.
 
const BehaviorContentGetBehavior (const gd::String &name) const
 Return a reference to the behavior called name.
 
bool HasBehaviorNamed (const gd::String &name) const
 Return true if object has a behavior called name.
 
void RemoveBehavior (const gd::String &name)
 Remove behavior called name.
 
bool RenameBehavior (const gd::String &name, const gd::String &newName)
 Change the name of behavior called name to newName. More...
 
gd::BehaviorContentAddBehavior (const gd::BehaviorContent &behavior)
 Add the specified behavior content to the object. More...
 
gd::BehaviorContentAddNewBehavior (gd::Project &project, const gd::String &type, const gd::String &name)
 Add the behavior of the specified type with the specified name. More...
 
const std::map< gd::String,
std::unique_ptr
< gd::BehaviorContent > > & 
GetAllBehaviorContents () const
 Get a read-only access to the map containing the behaviors with their properties.
 
const gd::VariablesContainerGetVariables () const
 Provide access to the gd::VariablesContainer member containing the object variables.
 
gd::VariablesContainerGetVariables ()
 Provide access to the gd::VariablesContainer member containing the object variables.
 
void SerializeTo (SerializerElement &element) const
 Serialize the object. More...
 
void UnserializeFrom (gd::Project &project, const SerializerElement &element)
 Unserialize the object. More...
 

Additional Inherited Members

- Protected Member Functions inherited from gd::Object
void Init (const gd::Object &object)
 
- Protected Attributes inherited from gd::Object
gd::String name
 The full name of the object.
 
gd::String type
 
std::map< gd::String,
std::unique_ptr
< gd::BehaviorContent > > 
behaviors
 
gd::VariablesContainer objectVariables
 List of the variables of the object.
 
gd::String tags
 Comma-separated list of tags.
 

Detailed Description

Standard sprite object for extensions that implements the standard SpriteExtension (see gd::BuiltinExtensionsImplementer::ImplementsSpriteExtension).

A Sprite object is an object composed of animations, containing directions with images.

See also
Animation
Direction
Sprite
gd::BuiltinExtensionsImplementer::ImplementsSpriteExtension

Member Function Documentation

std::unique_ptr<gd::Object> gd::SpriteObject::Clone ( ) const
inlineoverridevirtual

Must return a pointer to a copy of the object. A such method is needed to do polymorphic copies. Just redefine this method in your derived object class like this:

return gd::make_unique<MyObject>(*this);

Reimplemented from gd::Object.

void gd::SpriteObject::ExposeResources ( gd::ArbitraryResourceWorker worker)
overridevirtual

Called ( e.g. during compilation ) so as to inventory internal resources and sometimes update their filename. Implementation example:

worker.ExposeImage(myImage);
worker.ExposeFile(myResourceFile);
See also
ArbitraryResourceWorker

Reimplemented from gd::Object.

std::map< gd::String, gd::PropertyDescriptor > gd::SpriteObject::GetInitialInstanceProperties ( const gd::InitialInstance instance,
gd::Project project,
gd::Layout layout 
)
overridevirtual

Called when the IDE wants to know about the custom properties of an initial instance of this object.

Returns
a std::map with properties names as key and values.
See also
gd::InitialInstance

Reimplemented from gd::Object.

std::map< gd::String, gd::PropertyDescriptor > gd::SpriteObject::GetProperties ( gd::Project project) const
overridevirtual

Called when the IDE wants to know about the custom properties of the object.

Usage example:

std::map<gd::String, gd::PropertyDescriptor> properties;
properties[ToString(_("Text"))].SetValue("Hello world!");
return properties;
Returns
a std::map with properties names as key.
See also
gd::PropertyDescriptor

Reimplemented from gd::Object.

bool gd::SpriteObject::UpdateInitialInstanceProperty ( gd::InitialInstance instance,
const gd::String name,
const gd::String value,
gd::Project project,
gd::Layout layout 
)
overridevirtual

Called when the IDE wants to update a custom property of an initial instance of this object.

Returns
false if the new value cannot be set
See also
gd::InitialInstance

Reimplemented from gd::Object.

bool gd::SpriteObject::UpdateProperty ( const gd::String name,
const gd::String value,
gd::Project project 
)
overridevirtual

Called when the IDE wants to update a custom property of the object.

Returns
false if the new value cannot be set

Reimplemented from gd::Object.


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