Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


Programming a 2D spritesheet animation system


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 Sabo   Members   -  Reputation: 168

Like
0Likes
Like

Posted 24 May 2013 - 11:55 AM

I am about to start working on a 2D animation system using spritesheets. Below are my plans for this system, but before I implement it I thought I would ask for some thoughts and opinions.

 

  • Not all frames in all animations are of the same size. I then map each frame to a rectangle with the size of the frame which will save me a few bytes of memory.
  • I plan to have an array of frame times to allow different frame time for each frame. Will make it easier to control the animation.

Good? Bad?

 

I am also curious about how to best implement some kind of achor point. A simple example, a guy is standing straight (thin and high frame), then falling over (wide and low frame). Using either of the corners as an anchor point, the "standard/default" way, would result in the guy not only falling over, but also moving sideways on the screen. To solve this the anchor point needs to be set to the feet. Right? If so, I will also need an array for the anchor point for each frame, where the anchor point will indicate how much to move the sprite up/down and left/right. Or?

 

Am I missing something? Better way of doing things?



Sponsor:

#2 AllEightUp   Moderators   -  Reputation: 4270

Like
1Likes
Like

Posted 24 May 2013 - 11:59 AM

While not completely what you may be looking for, you might take a look at http://esotericsoftware.com/ at least as an example.  While it is a multi-piece system instead of single image animations, the basic concepts are likely going to be very similar at the base level.  Given the provided open source runtimes, it may save you time to take a look.



#3 Sabo   Members   -  Reputation: 168

Like
0Likes
Like

Posted 24 May 2013 - 12:08 PM

While not completely what you may be looking for, you might take a look at http://esotericsoftware.com/ at least as an example.  While it is a multi-piece system instead of single image animations, the basic concepts are likely going to be very similar at the base level.  Given the provided open source runtimes, it may save you time to take a look.

Hmm... I had not planned to use skeletal animation for this particular game. Either way, big thanks for the link. I will definitely have a closer look at their stuff since chances are I will use skeletal animation in a coming project. Might even change my mind for the current project.



#4 jms bc   Members   -  Reputation: 445

Like
2Likes
Like

Posted 24 May 2013 - 01:49 PM

You've pretty much covered what I have in my sprite code. My reference point is beneath the center of gravity of the figure, where the ground would be if the unit were standing. This is also marks the vertical displacement of the unit in the position vector. If I could go back, I think I would just make the reference point the center of gravity of the unit.

 

Actually, if I could go back in time, I would do a skeletal system.

 

Edit: no, really, if I could go back, I would use a 3rd party tool...


Edited by jms bc, 24 May 2013 - 01:50 PM.

The Four Horsemen of Happiness have left.


#5 sox   Crossbones+   -  Reputation: 484

Like
1Likes
Like

Posted 24 May 2013 - 02:38 PM

I'd allow for points and boxes to added to each frame as metadata.  In addition to allowing a "center of gravity" element, it would enable the following features to be added trivially:

 

1) collision boxes (often not the same as the sprite boundaries)

2) vulnerability / attack boxes (the intersection of a player's vuln. box and an enemy's attack box would trigger damage, for example)

3) spawn points for bullets

4) sound triggers (lets you play sfx for attacks, footsteps, etc., at precise timings)

 

I've used systems like this in the past, and they can be surprisingly powerful.  You could write a fairly simple tool in a day or two to let you graphically edit and place boxes and points in your sprite frames.

 

The variable-sized frames sound good, but I'd stick with fixed-size until you're sure that the memory savings is worth the complexity.

 

The time-per-frame is a good feature.  90% of the time, you'll want your frames to be evenly spaced, but i could see it coming in handy for some specific cases.

 

have fun!

 



#6 Sabo   Members   -  Reputation: 168

Like
0Likes
Like

Posted 24 May 2013 - 11:19 PM

Alright. Thanks for the input. Good information in all posts. Will give it some more thought before I go ahead. Much appreciated.



#7 Nausea   Members   -  Reputation: 258

Like
0Likes
Like

Posted 19 June 2013 - 03:17 PM

I am about to start working on a 2D animation system using spritesheets. Below are my plans for this system, but before I implement it I thought I would ask for some thoughts and opinions.

 

  • Not all frames in all animations are of the same size. I then map each frame to a rectangle with the size of the frame which will save me a few bytes of memory.
  • I plan to have an array of frame times to allow different frame time for each frame. Will make it easier to control the animation.

Good? Bad?

 

I am also curious about how to best implement some kind of achor point. A simple example, a guy is standing straight (thin and high frame), then falling over (wide and low frame). Using either of the corners as an anchor point, the "standard/default" way, would result in the guy not only falling over, but also moving sideways on the screen. To solve this the anchor point needs to be set to the feet. Right? If so, I will also need an array for the anchor point for each frame, where the anchor point will indicate how much to move the sprite up/down and left/right. Or?

 

Am I missing something? Better way of doing things?

 

I'm a noob but I guess I could tell you how I did this.

 

I used a Animation class to handle the animation itself. Then it had a list of Frameset class instances and a pointer to the current Frameset which it used to loop over it.

The Frameset class had a list of Frames and ability to add Frames etc. The Frame class had x/y cords for the image and offsets and some more stuff.

 

I hope you get the idea, some time ago since I coded it.

 

Maybe someone with actual skill can tell you how much my version sucks. :)






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS