Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Dividing a sprite sheet into individual usable images  (Read 1739 times)

0 Members and 1 Guest are viewing this topic.

Intrexa

  • Newbie
  • *
  • Posts: 2
    • View Profile
Dividing a sprite sheet into individual usable images
« on: January 27, 2011, 03:32:31 am »
I have sprite sheets of character animations sized roughly 640x640 each, with each individual sprite being 80x80. My current method of using these sheets is to load the entire image into an sf::image, then subdivide each 80x80 animation into a vector, then make a map<string, &sf::image> so that I can name things easier, such as DennisWalk0 - DennisWalk4 for walking animations. Individual sprites will refer to the map to get the needed image. I'm curious if anyone would like to share with me a better, more efficient, or easier to use way of doing this. It's a pain, because say on 1 sheet block 3x3 is a walk animation, but on another sheet block 3x3 might be an attack animation, so each sheet needs me to hardcode and individually name maybe 60 animations, and I have maybe 40 sheets that I want to use.

Walker

  • Full Member
  • ***
  • Posts: 181
    • View Profile
Dividing a sprite sheet into individual usable images
« Reply #1 on: January 28, 2011, 12:39:30 pm »
I am not sure why you need to keep individual sf::Images for each frame. Personally, for animations, I keep one image (in a resource manager somewhere) and have one sprite that gets its subrect updated to the next frame. I'm pretty sure the animation examples in the wiki all work in a similar way.

If you need to define things like FPS or the number of frames outside of code, it should be simple enough to have a file that keeps info on all your animations (or one file per image/anim).

 

anything