Hi, I had a question about how to use AtlasSprites when I have different animations for my character. Unfortunately I can't fit all my animations on one sheet like in most of the examples here, so I had to use different AtlasSpriteManagers for each one. Since each manager needs to have the sprite as a child, would you add the same sprite as a child to multiple managers? Or do you have to create a separate sprite for each manager? Thanks for any help
AtlasSprite question
(7 posts) (4 voices)-
Posted 2 years ago #
-
You could create a layer that would encapsulate both sprite managers, each with their sprites. Then show / hide the appropriate manager inside the layer for the given animation.
Any reason you couldn't edit to get the animations for a character into a single sprite sheet? Just out of curiosity. =)
Posted 2 years ago # -
I use something similar to this method (basically what exorcyze suggested):
http://johnehartzog.com/2009/05/using-cocos2d-atlasspritemanager/for flipping between 3 different sprite sheets for a single character (it has ALOT of different animations!)
I tried using a single AtlasSprite & changing its texture property when needed, but found their was often a very slight (but noticeable) lag/jitter, even with the images preloaded. So went with multiple sprites instead.
hope that helps.
Posted 2 years ago # -
Thanks for the suggestion, that sounds like a good way to go. I will try that and let you guys know how it turns out.
@exorcyze: Now that you mention it, maybe it's possible... I just hadn't considered earlier because my main character is a lemur and has multiple actions like an idle animation, a walk animation, a few different throw animations, and a spin animation, and the artist gave me maybe half a dozen cells for each action. What's the max size of a sprite sheet? 1024x1024? If that's the case I could still fit 64 128x128 pixel which would probably be enough. Do you think that'd be a better approach? Just having one large sprite sheet as opposed to smaller sheets but multiple ASMs?
Anyways thanks for your replies, I really appreciate it. When it comes to objC I'm still a noob at it (I started last week!)
Posted 2 years ago # -
I only use one sprite sheet if I can, it's less to keep track of in code.
Posted 2 years ago # -
I agree. If you can fit it on 1 sprite sheet, that keeps your code much, much simpler!
Posted 2 years ago # -
I think combining into a single sheet would simplify things tremendously from a code standpoint. Though it's not always possible on a project which is why I asked. The memory consumed for the image(s) would be the same, though there could possibly be some gains with cocos only having one texture to track - not positive on that though.
Personally, I'm still trying to adjust to having the texture be a parent of the sprite rather than a property. It keeps throwing me off for composing things! =)
Good luck!
Posted 2 years ago #
Reply
You must log in to post.