JugiMap Framework
StandardSprite Class Reference

The StandardSprite class defines the sprite from JugiMap Editor. More...

#include <jmSprites.h>

Inherits Sprite.

Inherited by StandardSpriteAGK, StandardSpriteCC, StandardSpriteNC, and StandardSpriteSFML.

Public Types

enum  PhysicsMode { NO_PHYSICS =0, STATIC =1, DYNAMIC =2, KINEMATIC =3 }
 The physics mode of the standard sprite. More...
 
- Public Types inherited from Sprite
enum  Property
 The Property enumerator provides flags for sprite properties. More...
 

Public Member Functions

 StandardSprite ()
 Constructor. More...
 
void UpdateBoundingBox () override
 Update the map bounding box of this sprite. More...
 
virtual bool HasCollider () override
 Returns true if this sprite has assigned a collider; otherwise returns false. More...
 
virtual bool PointInside (Vec2f _pos) override
 Returns true if the given point **_pos** is inside the shape(s) of this sprite; otherwise returns false. More...
 
virtual bool Overlaps (Sprite *_sprite) override
 Returns true if the shapes of this and the given **_sprite** overelaps; otherwise returns false. More...
 
virtual bool RaycastHit (Vec2f _rayStart, Vec2f _rayEnd, Vec2f &_hitPos) override
 Returns true if a ray (line segment) from **_rayStart** to **_rayEnd** 'hits' at the shape(s) of this sprite; otherwise return false. More...
 
GraphicItemGetActiveImage ()
 Returns the active image. More...
 
virtual void SetActiveImage (GraphicItem *_image)
 Set the active image to the given *_image*. More...
 
int GetActiveImageFrameIndex ()
 Returns the index of the active image in the source sprite's graphic items vector. More...
 
void SetActiveImageByFrameIndex (int _frameIndex)
 Set the active image to the image at the given *_frameIndex* in the source sprite's graphic items vector. More...
 
void SetCollider (Collider *_collider)
 Set collider to the given *_collider*. More...
 
Collider * GetCollider ()
 Returns the collider or nullptr if none. More...
 
virtual PhysicsMode GetPhysicsMode ()
 Returns the physics mode. More...
 
virtual void SetPhysicsMode (PhysicsMode _physicsMode)
 Set the physics mode to the given *_physicsMode*. More...
 
virtual void AppendAnimatedProperties (AnimatedProperties &_ap) override
 Set sprite properties from the given **_ap** object. More...
 
- Public Member Functions inherited from Sprite
 Sprite ()
 Constructor. More...
 
SpriteMakePassiveCopy ()
 Create a new sprite which is a passive copy of this sprite. More...
 
SpriteMakeActiveCopy ()
 Create a new sprite which is an active copy of this sprite. More...
 
virtual void CopyProperties (Sprite *_sprite, int copyFlags)
 Copy properties from the given **_sprite**. More...
 
virtual void InitEngineObjects ()
 Initialize the engine sprite. More...
 
virtual void UpdateEngineObjects ()
 Update the engine sprite. More...
 
virtual void DrawEngineSprite ()
 Draw the engine sprite. More...
 
virtual bool IsEngineSpriteInitialized ()
 Returns true if the engine sprite of this sprite has been initialized; otherwise returns false. More...
 
virtual void SetVisible (bool _visible)
 Set the visibility of this sprite. More...
 
bool IsVisible ()
 Returns true if this sprite is visible; otherwise returns false. More...
 
void SetDisabledEngineSpriteUpdate (bool _engineSpriteUsedDirectly)
 Set a boolean flag which indicates if this sprite's engine sprite is used directly. More...
 
bool IsEngineSpriteUsedDirectly ()
 Returns true if this sprite's engine sprite is used directly. More...
 
Rectf GetBoundingBox ()
 Returns the world bounding rectangle of this sprite. More...
 
virtual void CaptureForLerpDrawing ()
 Capture the sprite properties, usually the position only, required for the lerp drawing. More...
 
SpriteLayerGetLayer ()
 Returns a sprite layer where this sprite is stored. More...
 
SourceSpriteGetSourceSprite ()
 Returns the source sprite of this sprite. More...
 
ComposedSpriteGetParentComposedSprite ()
 Returns the parent composed sprite of this sprite. More...
 
SpriteKind GetKind ()
 Returns the kind of this sprite. More...
 
void SetId (int _id)
 Set the id of this sprite to the given _id. More...
 
int GetId ()
 Returns the id of this sprite. More...
 
void SetName (const std::string &_nameID)
 Set the name of this sprite to the given _nameID. More...
 
std::string GetName ()
 Returns the name of this sprite. More...
 
void SetTag (int _tag)
 Set the tag of this sprite to the given _tag. More...
 
int GetTag ()
 Returns the tag of this sprite. More...
 
void SetCustomObject (CustomObject *_customObject)
 Assign a custom object of this sprite to the given _customObject. More...
 
CustomObjectGetCustomObject ()
 Returns the custom object of this sprite if exists; otherwise returns nullptr. More...
 
std::vector< jugimap::Parameter > & GetParameters ()
 Returns a reference to the vector of stored parameters in this sprite. More...
 
int GetDataFlags ()
 Returns the dataFlags of this sprite. More...
 
void SetPosition (Vec2f _position)
 Set the position of this sprite to the given **_position**. More...
 
Vec2f GetPosition (bool _includeAnimatedProperties=true)
 Returns the position of this sprite. More...
 
Vec2f GetGlobalPosition (bool _includeAnimatedProperties=true)
 Returns the global position of this sprite. More...
 
void SetScale (Vec2f _scale)
 Set the horizontal and vertical scale factor of this sprite to the given **_scale**. More...
 
Vec2f GetScale (bool _includeAnimatedProperties=true)
 Returns the horizontal and vertical scale factor of this sprite. More...
 
Vec2f GetGlobalScale (bool _includeAnimatedProperties=true)
 Returns the global scale factor of this sprite. More...
 
void SetRotation (float _rotation)
 Set the rotation of this sprite to the given **_rotation**. More...
 
float GetRotation (bool _includeAnimatedProperties=true)
 Returns the rotation of this sprite in degrees. More...
 
float GetGlobalRotation (bool _includeAnimatedProperties=true)
 Returns the global rotation of this sprite. More...
 
void SetFlip (Vec2i _flip)
 Set the horizontal and vertical flip factor of this sprite to the given **_flip**. More...
 
Vec2i GetFlip (bool _includeAnimatedProperties=true)
 Returns the horizontal and vertical flip factor of this sprite. More...
 
Vec2i GetGlobalFlip (bool _includeAnimatedProperties=true)
 Returns the horizontal and vertical world flip factor of this sprite. More...
 
virtual void SetHandle (Vec2f _handle)
 Set the handle point of this sprite to the given **_handle** point. More...
 
Vec2f GetHandle ()
 Returns the handle point of this sprite. More...
 
void SetAlpha (float _alpha)
 Set the alpha of this sprite to the given **_alpha**. More...
 
float GetAlpha (bool _includeAnimatedProperties=true)
 Returns the alpha of this sprite. More...
 
void SetOwnBlend (Blend _blend)
 Set the own blend of this sprite to the given **_blend**. More...
 
Blend GetOwnBlend ()
 Returns the own blend of this sprite. More...
 
void SetColorOverlayActive (bool _colorOverlayActive)
 Set to true to make the color overlay active; set to false to disable the color overlay. More...
 
bool IsOverlayColorActive ()
 Returns true if the overlay color of this sprite is active; otherwise returns false. More...
 
void SetColorOverlayRGBA (ColorRGBA _colorOverlayRGBA)
 Set the color overlay of this sprite to the given **_colorOverlayRGBA**. More...
 
ColorRGBA GetOverlayColorRGBA (bool _includeAnimatedProperties=true)
 Returns the overlay color of this sprite. More...
 
void SetColorOverlayBlend (ColorOverlayBlend _colorOverlayBlend)
 Set the color overlay blend of this sprite to the given **_colorOverlayBlend**. More...
 
ColorOverlayBlend GetOverlayColorBlend (bool _includeAnimatedProperties=true)
 Returns the overlay color blend of this sprite. More...
 
AnimatedProperties * GetAnimatedProperties ()
 Returns the pre-animation properties. More...
 
virtual void CreateAnimatedPropertiesIfNone ()
 Store current properties for animation purposes. More...
 
virtual void ResetAnimatedProperties ()
 Set sprite properties to pre-animation state. More...
 
void SetChangeFlags (int _changeFlags)
 Set the change flags of this sprite to the given *_changeFlags*. More...
 
void AppendToChangeFlags (int _changeFlags)
 Append the given *_changeFlags* to the change flags of this sprite with a biwise operation. /// The *_changeFlags* must be a value or a bitwise combination of values defined in the Property enumerator. More...
 
int GetChangeFlags ()
 Returns the change flags of this sprite. More...
 
void _SetSourceSprite (SourceSprite *_sourceSprite)
 Set the source sprite of this sprite to the given **_sourceSprite**. More...
 
void _SetLayer (SpriteLayer *_spriteLayer)
 Set the layer of this sprite to the given **_sourceSprite**. More...
 

Protected Member Functions

virtual ~StandardSprite ()
 Destructor. More...
 
- Protected Member Functions inherited from Sprite
virtual ~Sprite ()
 Destructor. More...
 

Detailed Description

The StandardSprite class defines the sprite from JugiMap Editor.

Member Enumeration Documentation

◆ PhysicsMode

The physics mode of the standard sprite.

Enumerator
NO_PHYSICS 

Not included in the physics simulation.

STATIC 

Included in the physics simulation as a static object.

DYNAMIC 

Included in the physics simulation as a dynamic object.

KINEMATIC 

Included in the physics simulation as a kinematic object.

Constructor & Destructor Documentation

◆ StandardSprite()

StandardSprite ( )
inline

Constructor.

◆ ~StandardSprite()

~StandardSprite ( )
protectedvirtual

Destructor.

Member Function Documentation

◆ UpdateBoundingBox()

void UpdateBoundingBox ( )
overridevirtual

Update the map bounding box of this sprite.

The dimensions of bounding box are based on the size of the active texture. If a sprite is not scaled or rotated the bounding box and the texture have the same size. Usually you don't need to use this function as other functions call it when required.

Reimplemented from Sprite.

◆ HasCollider()

bool HasCollider ( )
overridevirtual

Returns true if this sprite has assigned a collider; otherwise returns false.

A collider is assigned to sprites which have SourceSprite with defined sprite shapes.

See also
Collider

Reimplemented from Sprite.

◆ PointInside()

bool PointInside ( Vec2f  _pos)
overridevirtual

Returns true if the given point **_pos** is inside the shape(s) of this sprite; otherwise returns false.

The given point must be in global coordinate system. This function uses a sprite collider to obtain the result. It returns false if this sprite has no collider assigned.

See also
Collider

Reimplemented from Sprite.

◆ Overlaps()

bool Overlaps ( Sprite _sprite)
overridevirtual

Returns true if the shapes of this and the given **_sprite** overelaps; otherwise returns false.

This function uses sprite colliders to obtain the result. It returns false if one or both of sprites is without a collider.

See also
Collider

Reimplemented from Sprite.

◆ RaycastHit()

bool RaycastHit ( Vec2f  _rayStart,
Vec2f  _rayEnd,
Vec2f _hitPos 
)
overridevirtual

Returns true if a ray (line segment) from **_rayStart** to **_rayEnd** 'hits' at the shape(s) of this sprite; otherwise return false.

If the 'hit' occurs its position get stored in the given **_hitPos**. This function uses sprite colliders to obtain the result. It returns false if this sprite has no collider assigned.

See also
Collider

Reimplemented from Sprite.

◆ GetActiveImage()

GraphicItem* GetActiveImage ( )
inline

Returns the active image.

◆ SetActiveImage()

void SetActiveImage ( GraphicItem _image)
virtual

Set the active image to the given *_image*.

Important: The *_image* must be one of the images within the source sprite's graphic items. The *_image* can also be nullptr in which case the sprite will not be visible.

Reimplemented in StandardSpriteAGK, StandardSpriteNC, StandardSpriteSFML, and StandardSpriteCC.

◆ GetActiveImageFrameIndex()

int GetActiveImageFrameIndex ( )

Returns the index of the active image in the source sprite's graphic items vector.

If the active image is nullptr it returns -1.

◆ SetActiveImageByFrameIndex()

void SetActiveImageByFrameIndex ( int  _frameIndex)

Set the active image to the image at the given *_frameIndex* in the source sprite's graphic items vector.

The index must be inside the vector's bounds!

◆ SetCollider()

void SetCollider ( Collider *  _collider)
inline

Set collider to the given *_collider*.

This function is called at the sprite initialization.

◆ GetCollider()

Collider* GetCollider ( )
inline

Returns the collider or nullptr if none.

◆ GetPhysicsMode()

virtual PhysicsMode GetPhysicsMode ( )
inlinevirtual

Returns the physics mode.

This function can be used with engines which provides a physics simulation engine.

◆ SetPhysicsMode()

virtual void SetPhysicsMode ( PhysicsMode  _physicsMode)
inlinevirtual

Set the physics mode to the given *_physicsMode*.

This function can be used with engines which provides a physics simulation engine.

Reimplemented in StandardSpriteAGK, and StandardSpriteCC.

◆ AppendAnimatedProperties()

void AppendAnimatedProperties ( AnimatedProperties &  _ap)
overridevirtual

Set sprite properties from the given **_ap** object.

This function is usually called from animation objects.

See also
Collider

Reimplemented from Sprite.


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