Oficina Framework  1.3
Games Framework
OficinaFramework::RenderingSystem::Animation Class Reference

Represents an Animation, a set of controls for animating objects using SpriteSheets. More...

#include <RenderingSystem.hpp>

Classes

struct  AnimationSpecs
 A struct representing the specs of a single animation. More...
 

Public Member Functions

 Animation (SpriteSheet *sheet)
 Constructs an animation. More...
 
 ~Animation ()
 Desructs the animation. More...
 
void update ()
 Updates the animation. More...
 
void Draw (vec2 Position, float magnification, Color4 tint, RenderEffect re=MODULATE_EFFECT)
 Draws the animation. More...
 
void dispose ()
 Disposes the animation. More...
 
SpriteSheetGetSpriteSheet ()
 Gets the SpriteSheet of this Animation. More...
 
void RegisterAnimation (std::string AnimationName, word frame_begin, word frame_end, float speed)
 Registers an animation on the database of this Animation class. More...
 
void RegisterAnimation (std::string AnimationName, word frame_begin, word frame_end, word frame_loop, float speed)
 Registers an animation on the database of this Animation class. More...
 
void RegisterAnimation (std::string AnimationName, AnimationSpecs specs)
 Registers an animation on the database of this Animation class. More...
 
float GetAnimationSpeed () const
 Gets the current speed of the animation. More...
 
void SetAnimationSpeed (float speed)
 Sets the current speed of the animation. More...
 
void SetAnimation (std::string AnimationName)
 Sets the current animation, if registered. More...
 
void SetOrientation (RenderProperty rp)
 Sets the orientation of the animation. More...
 
RenderProperty GetOrientation () const
 Gets the orientation of the animation. More...
 
std::string GetCurrentAnimationName () const
 Gets the name of the currently playing animation. More...
 
dword GetCurrentFrame () const
 Gets the current animation frame playing. More...
 
vec2dw GetFrameSize () const
 Gets the size of a single frame. More...
 
void SetAngle (float angle)
 Sets the current animation angle. More...
 
float GetAngle () const
 Gets the current animation angle. More...
 
void SetAlpha (float alpha)
 Sets the alpha ratio of the animation. More...
 
float GetAlpha () const
 Gets the alpha ratio of the animation. More...
 
float GetDefaultAnimationSpeed () const
 Gets the default animation speed. More...
 
vec2 GetHotspot () const
 Gets the hotspot of the animation. More...
 
void SetSyncToFramerate (bool state)
 Sets or unsets whether the animation should synchonized to the current framerate. More...
 
bool IsSyncToFramerate ()
 Gets whether the animation is synchronized to the current framerate. More...
 

Detailed Description

Represents an Animation, a set of controls for animating objects using SpriteSheets.

Constructor & Destructor Documentation

◆ Animation()

OficinaFramework::RenderingSystem::Animation::Animation ( SpriteSheet sheet)

Constructs an animation.

Parameters
sheetPointer to the SpriteSheet containing the frames to be used.

◆ ~Animation()

OficinaFramework::RenderingSystem::Animation::~Animation ( )

Desructs the animation.

Member Function Documentation

◆ dispose()

void OficinaFramework::RenderingSystem::Animation::dispose ( )

Disposes the animation.

◆ Draw()

void OficinaFramework::RenderingSystem::Animation::Draw ( vec2  Position,
float  magnification,
Color4  tint,
RenderEffect  re = MODULATE_EFFECT 
)

Draws the animation.

Parameters
PositionPosition of the center of the animation to be used.
magnificationMagnification of the frame. Defaults to 1.0.
Warning
Use of this to simulate zoom is disencouraged.
Parameters
tintColor to tint the sprite. Defaults to White (1.0f, 1.0f, 1.0f, 1.0f). The alpha factor will be used to measure intensity of tinting.
reEffect when rendering the texture. Defaults to MODULATE_EFFECT.

◆ GetAlpha()

float OficinaFramework::RenderingSystem::Animation::GetAlpha ( ) const

Gets the alpha ratio of the animation.

Returns
Alpha ratio of the animation, ranged 0~1.

◆ GetAngle()

float OficinaFramework::RenderingSystem::Animation::GetAngle ( ) const

Gets the current animation angle.

Returns
The angle of the animation, in degrees.

◆ GetAnimationSpeed()

float OficinaFramework::RenderingSystem::Animation::GetAnimationSpeed ( ) const

Gets the current speed of the animation.

Returns
The current duration of frames on the animation, ranged 0.01f~1.0f.

◆ GetCurrentAnimationName()

std::string OficinaFramework::RenderingSystem::Animation::GetCurrentAnimationName ( ) const

Gets the name of the currently playing animation.

Returns
The name of the animation that is currently being played.

◆ GetCurrentFrame()

dword OficinaFramework::RenderingSystem::Animation::GetCurrentFrame ( ) const

Gets the current animation frame playing.

Returns
The frame number on the SpriteSheet.

◆ GetDefaultAnimationSpeed()

float OficinaFramework::RenderingSystem::Animation::GetDefaultAnimationSpeed ( ) const

Gets the default animation speed.

Returns
The default animation speed, or 0.0f in case of no animation.

◆ GetFrameSize()

vec2dw OficinaFramework::RenderingSystem::Animation::GetFrameSize ( ) const

Gets the size of a single frame.

Returns
A vec2 with dword precision containing the size of one frame.

◆ GetHotspot()

vec2 OficinaFramework::RenderingSystem::Animation::GetHotspot ( ) const

Gets the hotspot of the animation.

Returns
The point set to be the center of the animation.

◆ GetOrientation()

RenderProperty OficinaFramework::RenderingSystem::Animation::GetOrientation ( ) const

Gets the orientation of the animation.

Returns
Orientation of the animation.

◆ GetSpriteSheet()

SpriteSheet* OficinaFramework::RenderingSystem::Animation::GetSpriteSheet ( )

Gets the SpriteSheet of this Animation.

Returns
A pointer to this animation's SpriteSheet.

◆ IsSyncToFramerate()

bool OficinaFramework::RenderingSystem::Animation::IsSyncToFramerate ( )

Gets whether the animation is synchronized to the current framerate.

Returns
Whether the sync property is active or not.
Warning
It is only advised to keep this on when running on fixed framerates.

◆ RegisterAnimation() [1/3]

void OficinaFramework::RenderingSystem::Animation::RegisterAnimation ( std::string  AnimationName,
word  frame_begin,
word  frame_end,
float  speed 
)

Registers an animation on the database of this Animation class.

Parameters
AnimationNameName for the animation to be recognized when called.
frame_beginFrame in which the animation begins on the SpriteSheet.
frame_endFrame in which the animation ends on the SpriteSheet.
speedSpeed of each frame of the animation in seconds.

◆ RegisterAnimation() [2/3]

void OficinaFramework::RenderingSystem::Animation::RegisterAnimation ( std::string  AnimationName,
word  frame_begin,
word  frame_end,
word  frame_loop,
float  speed 
)

Registers an animation on the database of this Animation class.

Parameters
AnimationNameName for the animation to be recognized when called.
frame_beginFrame in which the animation begins on the SpriteSheet.
frame_endFrame in which the animation ends on the SpriteSheet.
frame_loopFrame in which the animation loop begins on the SpriteSheet.
speedSpeed of each frame of the animation in seconds.

◆ RegisterAnimation() [3/3]

void OficinaFramework::RenderingSystem::Animation::RegisterAnimation ( std::string  AnimationName,
AnimationSpecs  specs 
)

Registers an animation on the database of this Animation class.

Parameters
AnimationNameName for the animation to be recognized when called.
specsSpecs of the animation.
See also
RenderingSystem::Animation::AnimationSpecs

◆ SetAlpha()

void OficinaFramework::RenderingSystem::Animation::SetAlpha ( float  alpha)

Sets the alpha ratio of the animation.

Parameters
alphaAlpha ratio to be given to the animation, ranged 0~1.

◆ SetAngle()

void OficinaFramework::RenderingSystem::Animation::SetAngle ( float  angle)

Sets the current animation angle.

Parameters
angleAngle to be given to the animation, in degrees.

◆ SetAnimation()

void OficinaFramework::RenderingSystem::Animation::SetAnimation ( std::string  AnimationName)

Sets the current animation, if registered.

Parameters
AnimationNameName for the animation to be played.

◆ SetAnimationSpeed()

void OficinaFramework::RenderingSystem::Animation::SetAnimationSpeed ( float  speed)

Sets the current speed of the animation.

Parameters
speedNew duration for each frame of the animation, ranged 0.01f~1.0f.

◆ SetOrientation()

void OficinaFramework::RenderingSystem::Animation::SetOrientation ( RenderProperty  rp)

Sets the orientation of the animation.

Parameters
rpOrientation to be given to the animation.

◆ SetSyncToFramerate()

void OficinaFramework::RenderingSystem::Animation::SetSyncToFramerate ( bool  state)

Sets or unsets whether the animation should synchonized to the current framerate.

Parameters
stateState to be given to the sync property.
Warning
It is only advised to keep this on when running on fixed framerates.

◆ update()

void OficinaFramework::RenderingSystem::Animation::update ( )

Updates the animation.


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