Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i did animation through images but i want to do it through spritesheet
Posted

1 solution

 
Share this answer
 
Comments
Sweety Khan 30-Sep-11 7:59am    
thanx for answering. i m w8ng for so long.
but i dont want this method(textured rectangles). i want to do this by amethod in which gldrawpixels and may be glreadpixels are used
enhzflep 1-Oct-11 14:26pm    
Ah man!!
God ******* dammit! That's the 3rd or 4th time I've done that tonight - typed out a large reponse, hit the Reply thing above, only to realize I'd lost the whole post and yet AGAIN I'd neglected to hit the submit button. Sorry mate, it's 5:30am here - not up for re-typing all that right now. I'll get back to this question.

AND post a thread in Site Bgs/Sugestions..... grrrrrrrrr
Sweety Khan 1-Oct-11 15:29pm    
ohh its ok. post it when easier. i will be w8ng.
enhzflep 1-Oct-11 18:29pm    
Alrighty then! Lets try this again.

Hmm, never used glReadPixels or glWritePixels. But in any case, my understanding is that it's an issue of selecting the appropriate portion of an image (the sprite in question) for display.

Are you familiar with the toolbar images used when creating an app using (say) Visual Studio? If you're not, it's basically an image that contains all of the icons to be used on a toolbar.

It's 1 element high and n elements wide. As an example - it may be 64x16 pixels, this would infer that there are 4 images of 16x16 next-to each other horizontally.
To get to any particular image, we know that it's y coords will be 0 and imgHeight-1 (these are constant for all icons in the image) We also know that the second X coord will be 16 pixels further to the right than the first X coord. But how to find the first X corord of any of these images? Simple - we use something like firstXcoord = iconNumber * 16
For icon0 this will give us 0 and for icon3 this will give us 48. Perfect!

So, now imagine if you will that we make this strip wider - such that it can hold more frames of the animation. Great, but does that mean that we need a seperate image for each sprite we want to animate. Nah - we just stack these short,wide rows upon each other to give a single image holding a bunch of frames for a bunch of sprites.

(Is this indeed the subject of the query?)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900