Sign in to follow this  
QuackCoder

Sprite handling

Recommended Posts

I know about sprites and sprite sheets so far I thought I would divide stuff up into
1. ROWS: Having sprites of the same state like walking
2. COLUMN: Each frames of animation, including directional variations.

My problem:
Each state may not have the same amount of frames. Like walking and standing still, how do I manage that?
I heard about control files but I really dont know about them.

How should a sprite class handle states and frames? Or how should I make the spritesheet to aid me coding afterwards?

Share this post


Link to post
Share on other sites
[quote name='QuackCoder' timestamp='1318176039' post='4870829']
Each state may not have the same amount of frames. Like walking and standing still, how do I manage that?
I heard about control files but I really dont know about them.
[/quote]

The "control file" can simply be a text file that describes the amount of frames, and were those frames are on the atlas. ie I like using xml for my config files.
[code]
<animation>
<frame>
<uvCoords u1="0" u2="1" v1="0" v2="1" />
<size x="64" y="64" />
<offset x="0" y="0" z="0" />
</frame>
</animation>
[/code]

That describes a single frame in an animation, giving the uvCoords within the texture, and how far the frame needs to be offset to line up right. For different sized frame.

[quote]
How should a sprite class handle states and frames? Or how should I make the spritesheet to aid me coding afterwards?
[/quote]

A sprite class shouldn't handle states related to your game. In my current engine, I split sprites and animation apart. There is a sprite struct, and an animation class that uses sprites. Let the animation class handle what frame should be displayed when. Then think of your animation class as one single animation, it shouldn'y store multiple animations. Instead your character/player class/objects should store multiple animations, if they need more than one.

If you got a more specific question, I'd be glad to explain further.

Share this post


Link to post
Share on other sites
[quote name='freeworld' timestamp='1318183092' post='4870852']
A sprite class shouldn't handle states related to your game. In my current engine, I split sprites and animation apart. There is a sprite struct, and an animation class that uses sprites. Let the animation class handle what frame should be displayed when. Then think of your animation class as one single animation, it shouldn'y store multiple animations. Instead your character/player class/objects should store multiple animations, if they need more than one.[/quote]

Well said. +1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this