Game Development Community

Animation Across Multiple Spritesheets?

by Jesse Allen · in Torque 2D Beginner · 01/23/2014 (8:18 pm) · 4 replies

Greetings! I have been working with animating some sprites, which for the most part has been straightforward. I am using TexturePackerPro to create my spritesheets, which includes a 'multipack' feature. What this is for is if your sprite count and size are too great to fit on a single spritesheet. This will allow the remaining sprites to 'continue' on another spritesheet image file.

I would like to know if T2D supports calling on multiple spritesheets during a single animation? For example: The animation is too long and great in size to fit all of the sprites on a sheet, so the 2nd half of the animation carries over to another image. Will Torque let me change to frame 0 of a new spritesheet upon reaching the last frame of the first spritesheet?

For the most part one sheet is enough to get it done, but in some cases I'm wanting to animate larger sprites. I was thinking it may be possible to 'hack' the sprite just making it switch images through some function, but was hoping perhaps T2D had a more elegant solution. Cheers and hopefully someone can help out a bit :)

#1
01/23/2014 (8:46 pm)
I haven't seen a function that links animation assets. How about using the onAnimationEnd callback (not available for CompositeSprites)?
#2
01/23/2014 (9:39 pm)
Yeah, there's nothing that links animation assets together like that. Every AnimationAsset refers to a single ImageAsset only. And each particular animation (walk up, walk down, walk left, run, jump, etc) requires its own AnimationAsset as well.

For Sprites and Scrollers you can use the onAnimationEnd callback to switch animations, but the sprites inside a CompositeSprite do not have this callback unfortunately. There was a thread recently about this but adding the callback to composites is not a trivial matter.

I know callbacks are another "secret" area of the engine where there is not much documentation. I'm putting together a callback guide but it is missing the parameters used at the moment - so I haven't linked it on the wiki home page yet.

github.com/GarageGames/Torque2D/wiki/Callback-Guide
#3
01/23/2014 (10:16 pm)
Thanks for your quick replies guys :) I'll take a look at the Callbacks and perhaps that will help me along. Luckily I'm not trying to do this with the CompositeSprite! It's just a large planet sprite that has multiple frames it's using as it rotates. When I get time to try out the callbacks(probably tomorrow), I'll report here in case it works and anyone else needs an answer later about this. Thanks again!
#4
01/25/2014 (2:31 pm)
Okay I finally got a chance to try this out today. With a little bit of script to make the Animation's 'sheet' change to the next sheet depending on which sheet is active it works as expected. Although with the size of the sprites, this really won't be a feasible solution for me in this case. The first reason is that when the onAnimationEnd() callback occurs there is a noticeable hitch as it swaps the 'sheet'. Honestly I'm not sure if this is due to the size of the sprites or the fact that it's changing the entire 'sheet' at this point.

In any event, the second reason is that these are HD renders of a planet so all the renders it would take to do this would take somewhere around 300MB worth of image files. lol. For what I'm trying to accomplish here, I was just wanting to use this for a MainMenu backdrop so ~300MB seems pretty silly.

Potential Solution
Now, taking the HD renders and creating a movie out of them would knock that down to ~30MB which would be much more acceptable. Feasible in fact. Although I haven't seen any way to actually add in a movie file, say, into a GUI element. Really I haven't seen any support for that at all so I'm not sure I should use any full HD renders unless they are stills. Anyways, for now I'll just make something much smaller for the backdrop (although the ability to integrate a movie file into a GUI element, or into a scene at all, would be pretty useful).