Hello again!
After learning (some of) the ways of memory management in my last thread I come to you now with another question. I found textureatlascreator ( http://robertjpayne.com/textureatlascreator/ ) from one of Riq's old posts, and to my great joy I found it to be an excellent tool.
Now, I've managed to get a method up and running for reading the .plist file that textureatlascreator generates. I've also created an AtlasSpriteManager for my sprite sheet. Now, if someone has any neat ideas on how to make the process of creating new animations using the information in this .plist easier I'm all ears.
Code thus far:
// the file name of the plist is coordinates.plist, I read it using the getDictionary method, which returns the contents as a (you guessed it) NSDictionary.
NSDictionary *coordinatesList = [self getDictionary: @"coordinates"];
// The sprite sheet is called spritesheet1.png, I add it to the AtlasSpriteManager "mgr".
AtlasSpriteManager *mgr = [AtlasSpriteManager spriteManagerWithFile:@"spritesheet1.png" capacity:20];
// add "mgr" to the layer
[self addChild:mgr z:0 tag:666];
/*
Now here is where I'm stuck. I'd like to loop through the keys in coordinates.plist and add one frame in the animation for every key. The keys take on the name of the original filename of the picture, in this case sprite_test0001 all the way to sprite_test0020.png
x, y, w(idth) and h(eight) are all values inside the current "key" in the dictionary. If you've used textureatlascreator before, you are probably familiar with the format.
*/
AtlasAnimation *animation = [AtlasAnimation animationWithName:@"testing" delay:0.033];
for(int i=0;i<20;i++) {
// do something here to "get" the values for width, height, x and y for the current key.
[animation addFrameWithRect: CGRectMake(x, y, width, height) ];
}
Any input is welcome. As usual, I hope this can be valuable reference material for others as well as for myself and my own little pet project.
Best regards,
Nicke