Jump to content
  • Advertisement
Sign in to follow this  
ShdwMarth

2D Animations

This topic is 4515 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
Its hard to use a gif when your coding though because you can't control the animation of the gif so easily (if the gif is truly an animated gif.) Try switching the images yourself as its pretty instructional.

Share this post


Link to post
Share on other sites
I used to make my animated gifs in flash, there is an option where you can export them to gifs. Depending on what you're doing, flash is very useful if you're making the effects while you're doing the animation. If you have a serie of gif images ready for animation, you can use imageready and import all the images.

But is there any way to import animated gifs into a game? isn't the best way, to clip images out from a spritesheet?

Share this post


Link to post
Share on other sites
That's exactly what I'm trying to do password. I need to know how to make 2d animations for sprites and use them in my game. Thanks for the replies so far everyone.

Share this post


Link to post
Share on other sites
Ah, my pardon, i didn't realise you were animating the gifs only in the program and were manually animating the sprites in your game. Sorry dude!

Share this post


Link to post
Share on other sites
I've recently found the program Allegro Sprite Editor (ase). Does anyone know if that would be good for what I'm wanting to do?

Share this post


Link to post
Share on other sites
Personally, I would recommend you to do it yourself in the code, it's a better learning experience. I don't know how to do this exactly, in allegro (if that's what you're using), but it's the same aslong as it's 2d.

Let's say you have an image that is 500x500 with a character that is walking. If you want to animate the walking, you can cut out parts of the 500x500 image and put them into an array (most likely an array which holds structures) and the structure itself have x, y, width and height members which represents the area where it should cut out the character.

When you have added the wanted amount of structures which contains the coordinates and size of the current walking graphic. Create a variable that keeps track of which frame it is and use that for the array. When you're blitting an image to the screen, you use this array, so it knows which area it should clip out.

I guess the following function is used to blit surfaces in allegro:
blit(image, screen, 0, 0, 0, 0, 640, 480);

which means that the zeroes probably represents the coordinates. A fast example of how it could look like:
blit(image, screen, name[frame].x, name[frame].y, name[frame].w, name[frame].h, 640, 480);

the struct simply looks like this, in this case:
struct rect {
int x;
int y;
int w;
int h;
}

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!