2019-03-10 21:38:58 +01:00
2019-02-19 21:24:56 +01:00
2019-03-10 21:38:58 +01:00
2019-02-19 21:24:56 +01:00
2019-03-10 14:16:05 +01:00
2019-03-10 21:38:58 +01:00

animatedsprite for SFML

This is a (stupid) simple implementation of sprite animation for SFML. It contains two files:

  • animatedsprite.hpp
  • animatedsprite.cpp And those are all you need to get going. In the test/ directory you find a super small program using the animatedsprite provided utlities.

The Animation File Format

Animation files are just simple ASCII text files. See test/testanimations.txt as an example. Below the structure of each animation definition is described.

Comment lines in the file start with # which are ignored, along with empty lines.

Each animation starts with: animation MyAnimationName Followed by a collection of definition lines, which always have a leading single tab:

  • frame-origin x y
    • Where x and y are unsigned integers.
    • Where is the first sprite frame located in the spritesheet.
  • frame-size x y
    • Where x and y are unsigned integers.
    • How big is the sprite frame.
  • frame-step x y
    • Where x and y are unsigned integers.
    • How much the frame needs to be translated every new frame.
    • Usually identical to your frame-size, but useful for example for skipping every other frame.
  • frame-count n
    • Where n is an unsigned integer.
  • frame-time n
    • Where n is an unsigned integer and represents milliseconds.
  • reverse
    • If present it reverse the animation.
  • loop
    • If present it loops the animation by going back to the first frame after the last frame has been reached.
  • bounce
    • If present it loops the animation by going in reverse whenever the last frame has been reached.

The actual source code tells you most likely all you need to know:

unsigned const x = frameOrigin.x + (frameNumber * frameStep.x);
unsigned const y = frameOrigin.y + (frameNumber * frameStep.y);

Where x and y are the topleft coordinates of the sprite frame.

Description
No description provided
Readme MIT 37 KiB
Languages
C++ 98.4%
Makefile 1.6%