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.

AppGameKit Classic Chat / Animation frames vs subimages

Author
Message
Rich Dersheimer
AGK Developer
15
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 10th Apr 2012 18:21
I'm using a texture atlas for my graphics. Some of my sprites use animation frames, some don't. For the ones that don't I've just been setting them up with an animation and not ever changing the frame.

Then I decided to use subimages, which are easier, because some of the images aren't in easily-defined animation sizes. But when I load subimages, my graphic setup takes much longer.

So, is this because the atlas is being loaded each time I call the LoadSubImage() command?

Or is something else going on that makes it so much slower than just using the animation frame.

Does using an animation setup on a sprite use more memory?
Marl
13
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 10th Apr 2012 18:34
Quote: "Does using an animation setup on a sprite use more memory?"

I recall this being answered before, one of the Devs said not, that the sprites just use pointers to the image memory.

Sorry I don't have a link to the original reply.
Paul Johnston
TGC Developer
22
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 10th Apr 2012 19:25
AddSpriteAnimationFrame was recently found to have a memory leak that may cause a slow down, but as Marl says the atlas texture is only loaded once and point to that image when you load a sub image.
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 10th Apr 2012 19:28
Paul will this memory leak be fixed in 107 or is it hard to crush?
Paul Johnston
TGC Developer
22
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 10th Apr 2012 19:35
it's fixed
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 10th Apr 2012 21:04
yeah great Paul!
Rich Dersheimer
AGK Developer
15
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 10th Apr 2012 21:12 Edited at: 10th Apr 2012 21:24
Paul, how would you account for the loading slowdown when I add calls to LoadSubImage()? I've already loaded the atlas to use for sprite anims. When I use an anim frame for my "static" sprite, the splash screen is up for x seconds. When I use a LoadSubImage() call instead of using an anim frame for the sprite, the splash screen is up for x + y seconds, noticeably longer. Since it IS noticeably longer, I suspect LoadSubImage() is doing more than just pointing to the atlas, but I could certainly be wrong.

If neither method has any drawbacks (aside from load times) then I can just use single anim frames to get subimages onto my static sprites. It just takes a bit more effort to arrange all the images into "frame sized" dimensions.

EDIT: By the way, I'm not using AddSpriteAnimationFrame() at all, I'm setting up the sprite with an animation and then setting the frame to wherever the image is on the atlas. So, one atlas may have some "cells" that are 64x64, some that are 128x64, some that are 128x128, and so on.
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 10th Apr 2012 21:41
I thought animation frames had to be all same size!
I always sized them identical myself
Rich Dersheimer
AGK Developer
15
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 10th Apr 2012 21:51
bj, the size for each of a sprites frames must be the same, but a different sprite can use the same sheet with a different frame size.

For instance, if my atlas sheet is 128x128, one sprite can use four equal frames of 64x64 size, and another sprite can use the same sheet for two equal frames of 128x64. In this example, the first sprite might only display its first two frames, "on" and "off". The second sprite would be static and only ever use its second frame.

That's a simple example, my actual sprite sheets are 1024x1024 and contain several sets of anims and static images.
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 10th Apr 2012 23:55
Ah ok, now I understand you.

I thought you wanted to use 128x128 and 128x64 in the SAME animation!!!!!!!!!!!!!!
Paul Johnston
TGC Developer
22
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 11th Apr 2012 01:22
Can you send me some code demonstrating the slow down? As sub images should be faster to load than normal images since it is simply saving some UV coords for the sub image.
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 11th Apr 2012 09:30
Rich I have not noticed slowdown myself.

Can you add a timer to your program, and calculate the time difference from before the loading to after the loading, with & without the subimages?
Rich Dersheimer
AGK Developer
15
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 11th Apr 2012 15:00
Well, my apologies to y'all. I got home from work and fired up AppGameKit, and the delay was gone. I hadn't changed anything to do with loading images or subimages, but the delay was... gone.

Maybe it was some other part of my code, or just something going on with my computer.

I added a timer like bj said, and both with and without the subimages, it takes less than a second to set up 1000 sprites.

So, no problems with animation frames vs subimages, and again my apologies for the whole thing.

Onward!
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 11th Apr 2012 15:42
I always put in timers to check things, the mind sometimes can trick you!

Login to post a reply

Server time is: 2024-11-23 08:46:24
Your offset time is: 2024-11-23 08:46:24