Open erisco opened 12 years ago
Will there be a function access to set the correct x y coords to display, or will this be coded depending from which class it is called?
Corrected the return value of getFrame(...)
from SDL_image *
to SDL_Surface *
.
@StephenNu: Animator
returns pointers to instances of SDL_Surface
via getFrame(...)
. You can draw an SDL_Surface
wherever you want, since it is independent of coordinate systems.
This issue outlines the proposed Animation API.
The intent of the Animation API is to facilitate the animation of in-game Sprites.
Implementation details, such as the usage of spritesheets and xml definition files, are intentionally hidden.
Publicly accessible class:
Animator
Public attributes of
Animator
: nonePublic methods of
Animator
:void begin(string animation, uint playTimeMS)
Sets the animation toanimation
with a play time ofplayTimeMS
milliseconds.SDL_Surface *getFrame(uint timeMS)
Returns the frame that should be displayed attimeMS
milliseconds. In particular,timeMS = 0
will return the first frame of the current animation.void transition(string animation, uint transTimeMS, uint playTimeMS)
TakestransTimeMS
milliseconds to transition to animationanimation
. Animationanimation
will then play with a play time ofplayTimeMS
. Aftertransition(...)
is called,getFrame(timeMS = 0)
will return the first frame of the transition fortransTimeMS > 0
.bool hasAnimation(string animation)
Intended for testing and debugging purposes, this returns true iff animationanimation
exists.Errors:
hasAnimation(...)
, passing a non-existent animation name as ananimation
argument willassert(...)
.Notes:
uint playTimeMS
: If the animation is a loop,playTimeMS
is how long a cycle takes. If the animation is a sequence,playTimeMS
is how long the sequence takes (before stopping on the last frame).string animation
: Animation name. This name is agreed upon between the developers and the art department. For example, the stringship.idle
may refer to the idle animation of the player's ship.