Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CCSpriteFrameCache & CCAnimationCache Support. #9

Closed
psineur opened this issue Jan 3, 2012 · 0 comments
Closed

CCSpriteFrameCache & CCAnimationCache Support. #9

psineur opened this issue Jan 3, 2012 · 0 comments

Comments

@psineur
Copy link
Owner

psineur commented Jan 3, 2012

  1. Both CCAnimations & CCSpriteFrames are reused in many places in Cocos2D-iPhone to save memory.
    CCAnimate retains given CCAnimation instead of copying it.
    Also CCAnimation retains CCSpriteFrames, instead of copying them.
    This saves memory.
  2. Currently CCSpriteFrameCache & CCAnimationCache doesn't get saved by AMC at all.
    So if you have 50 sprites and they share the same Animatiom from CCAnimationCache - their frames will be saved & loaded independently.
  3. For editor - it will be very frustrating to change same animation in many places.
    As well as spriteFrames.

So here's the plan:

  1. Save key, while saving CCAnimation or CCSpriteFrame if they exist in CCAnimationCache or CCSpriteFrameCache respectively
  2. Always save all other properties when saving - even if key exist. Order of loading may vary, so we need that all CCAnimation or CCSPriteFrame dictionaryRepresentations can save themselves in corresponding cache.
  3. When loading - check for existanse of CCAnimation or CCSPriteFrame in Cache by given key.
    If it doesnt exist - save it in cache on load.
    If it exist - always use cached version. But check for equality and log any inequality between cached and curLoading version.

This approach will give us ability to load only used parts of CCAnimationCache & CCSpriteFramesCache & reuse CCAnimations & CCSpriteFrames without using a lot of memory for the same objects.
Also it can speed up loading process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant