Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Trying to understand sprite frames and the create animated sprite command

Author
Message
CSL
15
Years of Service
User Offline
Joined: 22nd Mar 2009
Location: USA
Posted: 25th Sep 2010 04:06
Consider the following snippet that uses the attached media file to display all the sprite frames:



It starts fine, but as soon as it gets to the 10th frame, all sprites seem off. At some point I would like to grab any of the frames within the image but right now, I can't using this method. I suspect the frames aren't the same size. But regardless, what would be the best approach to grabbing any particular frame from this image, even if the sprite dimensions are not the same?

CSL

Attachments

Login to view attachments
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 25th Sep 2010 23:24 Edited at: 25th Sep 2010 23:27
It's because it calculates the size of the frames based on the image size and how many frames you say the graphic has.

The image width is 640 and there are 18 frames across so Darkbasic calculates the width size 640 / 18 = 35.5. The image height is 400 and there are 11 frames down so it calculates 400 / 11 = 36.36. Because they both end up as being a decimal it throws it off a bit. If each frame was exactly the same distance from each other (centered in the frames just right) and if the calculation didn't end in a float it would grab the images better.

What's mainly throwing it off is the blank space at the right side and the bottom. 99% of the time we have to realign the sprite sheet graphics to work with our projects. Most artists are not programmers and they line up graphics by sight rather than exact pixels like we programmers need.

CSL
15
Years of Service
User Offline
Joined: 22nd Mar 2009
Location: USA
Posted: 26th Sep 2010 03:36
Quote: "
The image width is 640 and there are 18 frames across so Darkbasic calculates the width size 640 / 18 = 35.5. The image height is 400 and there are 11 frames down so it calculates 400 / 11 = 36.36. Because they both end up as being a decimal it throws it off a bit. If each frame was exactly the same distance from each other (centered in the frames just right) and if the calculation didn't end in a float it would grab the images better.

What's mainly throwing it off is the blank space at the right side and the bottom. 99% of the time we have to realign the sprite sheet graphics to work with our projects. Most artists are not programmers and they line up graphics by sight rather than exact pixels like we programmers need.
"


I used Microsoft Picture Manager and cropped the image from 640x400
to 612x374,making the 18x11 picture evenly divisible while keeping the sprites intact. Except for one or two images, the rest were aligned correctly. Thanks for pointing me in the right direction, cheers.

CSL

Login to post a reply

Server time is: 2024-11-23 07:35:38
Your offset time is: 2024-11-23 07:35:38