<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -9,6 +9,13 @@ From:
 LICENSE: Attribution-NonCommercial-ShareAlike 2.0
 
 
+SPRITE SHEETS
+-------------
+
+Resoruces/Images/spritesheet*
+
+LICENSE: unsure... don't use them in your project.
+
 
 TILES &amp; TILEMAP:
 ----------------</diff>
      <filename>LICENSE.artwork</filename>
    </modified>
    <modified>
      <diff>@@ -29,10 +29,7 @@
 	// weak reference
 	TextureAtlas *mAtlas;
 	int mAtlasIndex;
-	
-	// spriteManager. weak ref
-	AtlasSpriteManager *spriteManager;
-	
+
 	// texture pixels
 	CGRect mRect;
 
@@ -46,6 +43,9 @@
 	
 	// whether or not this Sprite needs to be updated in the Atlas
 	BOOL	dirty;
+	
+	// Animations that belong to the sprite
+	NSMutableDictionary *animations;
 }
 
 /** whether or not the Sprite needs to be updated in the Atlas */
@@ -74,28 +74,28 @@
 /** an Animation object used within Sprites to perform animations */
 @interface AtlasAnimation : NSObject &lt;CocosAnimation&gt;
 {
-	int					tag;
+	NSString			*name;
 	float				delay;
 	NSMutableArray		*frames;
 }
 
-@property (readwrite) int tag;
+@property (readwrite,assign) NSString *name;
 
 /* cocos animation */
 @property (readwrite,assign) float delay;
-@property (readwrite,retain) NSMutableArray *frames;
+@property (readonly) NSMutableArray *frames;
 
-/** creates an AtlasAnimation with an AtlasSpriteManager, a tag, delay between frames */
-+(id) animationWithTag:(int)tag delay:(float)delay;
+/** creates an AtlasAnimation with an AtlasSpriteManager, a name, delay between frames */
++(id) animationWithName:(NSString*)name delay:(float)delay;
 
-/** creates an AtlasAnimation with an AtlasSpriteManager, a tag, delay between frames and the AtlasSpriteFrames */
-+(id) animationWithTag:(int)tag delay:(float)delay frames:frame1,... NS_REQUIRES_NIL_TERMINATION;
+/** creates an AtlasAnimation with an AtlasSpriteManager, a name, delay between frames and the AtlasSpriteFrames */
++(id) animationWithName:(NSString*)name delay:(float)delay frames:frame1,... NS_REQUIRES_NIL_TERMINATION;
 
-/** initializes an Animation with an AtlasSpriteManger, a tag and delay between frames */
--(id) initWithTag:(int)tag delay:(float)delay;
+/** initializes an Animation with an AtlasSpriteManger, a name and delay between frames */
+-(id) initWithName:(NSString*)name delay:(float)delay;
 
-/** initializes an AtlasAnimation with an AtlasSpriteManager, a tag, and the AltasSpriteFrames */
--(id) initWithTag:(int)tag delay:(float)delay firstFrame:(AtlasSpriteFrame*)frame vaList:(va_list) args;
+/** initializes an AtlasAnimation with an AtlasSpriteManager, a name, and the AltasSpriteFrames */
+-(id) initWithName:(NSString*)name delay:(float)delay firstFrame:(AtlasSpriteFrame*)frame vaList:(va_list) args;
 
 /** adds a frame to an Animation */
 -(void) addFrameWithRect:(CGRect)rect;</diff>
      <filename>cocos2d/AtlasSprite.h</filename>
    </modified>
    <modified>
      <diff>@@ -21,6 +21,7 @@
 @interface AtlasSprite (Private)
 -(void)updateTextureCoords;
 -(void)updatePosition;
+-(void) initAnimationDictionary;
 @end
 
 @implementation AtlasSprite
@@ -38,10 +39,10 @@
 {
 	if( (self = [super init])) {
 		mAtlas = [manager atlas];	// weak reference. Don't release
-		spriteManager = manager;	// weak reference. Dont' release
 		
 		dirty = YES;
 
+		animations = nil;		// lazy alloc
 		[self setTextureRect:rect];
 	}
 
@@ -50,11 +51,12 @@
 
 - (NSString*) description
 {
-	return [NSString stringWithFormat:@&quot;&lt;%@ = %08X | Rect = (%i,%i,%i,%i) | Tag = %i&gt;&quot;, [self class], self, (int) mRect.origin.x, (int) mRect.origin.y, (int) mRect.size.width, (int) mRect.size.height, tag];
+	return [NSString stringWithFormat:@&quot;&lt;%@ = %08X | Rect = (%.2f,%.2f,%.2f,%.2f) | tag = %i&gt;&quot;, [self class], self, mRect.origin.x, mRect.origin.y, mRect.size.width, mRect.size.height, tag];
 }
 
 - (void) dealloc
 {
+	[animations release];
 	[super dealloc];
 }
 
@@ -274,6 +276,21 @@
 {
 	return [AtlasSpriteFrame frameWithRect:mRect];
 }
+// XXX: duplicated code. Sprite.m and AtlasSprite.m share this same piece of code
+-(void) addAnimation: (id&lt;CocosAnimation&gt;) anim
+{
+	// lazy alloc
+	if( ! animations )
+		[self initAnimationDictionary];
+	
+	[animations setObject:anim forKey:[anim name]];
+}
+// XXX: duplicated code. Sprite.m and AtlasSprite.m share this same piece of code
+-(id&lt;CocosAnimation&gt;)animationByName: (NSString*) animationName
+{
+	NSAssert( animationName != nil, @&quot;animationName parameter must be non nil&quot;);
+    return [animations objectForKey:animationName];
+}
 @end
 
 
@@ -281,35 +298,35 @@
 #pragma mark AltasAnimation
 
 @implementation AtlasAnimation
-@synthesize tag, delay, frames;
+@synthesize name, delay, frames;
 
-+(id) animationWithTag:(int)aTag delay:(float)d frames:rect1,...
++(id) animationWithName:(NSString*)aname delay:(float)d frames:rect1,...
 {
 	va_list args;
 	va_start(args,rect1);
 	
-	id s = [[[self alloc] initWithTag:aTag delay:d firstFrame:rect1 vaList:args] autorelease];
+	id s = [[[self alloc] initWithName:aname delay:d firstFrame:rect1 vaList:args] autorelease];
 	
 	va_end(args);
 	return s;
 }
 
-+(id) animationWithTag:(int)aTag delay:(float)d
++(id) animationWithName:(NSString*)aname delay:(float)d
 {
-	return [[[self alloc] initWithTag:aTag delay:d] autorelease];
+	return [[[self alloc] initWithName:aname delay:d] autorelease];
 }
 
--(id) initWithTag:(int)t delay:(float)d
+-(id) initWithName:(NSString*)t delay:(float)d
 {
-	return [self initWithTag:t delay:d firstFrame:nil vaList:nil];
+	return [self initWithName:t delay:d firstFrame:nil vaList:nil];
 }
 
-/** initializes an AtlasAnimation with an AtlasSpriteManager, a tag, and the frames from AtlasSpriteFrames */
--(id) initWithTag:(int)t delay:(float)d firstFrame:(AtlasSpriteFrame*)frame vaList:(va_list)args
+/** initializes an AtlasAnimation with an AtlasSpriteManager, a name, and the frames from AtlasSpriteFrames */
+-(id) initWithName:(NSString*)t delay:(float)d firstFrame:(AtlasSpriteFrame*)frame vaList:(va_list)args
 {
 	if( (self=[super init]) ) {
 	
-		tag = t;
+		name = t;
 		frames = [[NSMutableArray array] retain];
 		delay = d;
 		</diff>
      <filename>cocos2d/AtlasSprite.m</filename>
    </modified>
    <modified>
      <diff>@@ -360,6 +360,18 @@ enum {
 -(GLubyte) b;
 @end
 
+
+/// Objects that supports the Animation protocol
+@protocol CocosAnimation
+/** reaonly array with the frames */
+-(NSArray*) frames;
+/** delay of the animations */
+-(float) delay;
+/** name of the animation */
+-(NSString*) name;
+@end
+
+
 /// Nodes supports frames protocol
 @protocol CocosNodeFrames
 /** sets a new display frame to the node */
@@ -368,13 +380,9 @@ enum {
 -(BOOL) isFrameDisplayed:(id)frame;
 /** returns the current displayed frame */
 -(id) displayFrame;
+/** returns an Animation given it's name */
+-(id&lt;CocosAnimation&gt;)animationByName: (NSString*) animationName;
+/** adds an Animation to the Sprite */
+-(void) addAnimation: (id&lt;CocosAnimation&gt;) animation;
 @end
 
-/// Objects that supports the Animation protocol
-@protocol CocosAnimation
--(NSArray*) frames;
--(float) delay;
-@end
-
-
-</diff>
      <filename>cocos2d/CocosNode.h</filename>
    </modified>
    <modified>
      <diff>@@ -57,12 +57,8 @@
 -(id) initWithTexture:(Texture2D*) tex;
 
 
-/** adds an Animation to the Sprite */
--(void) addAnimation: (Animation*) animation;
 /** changes the display frame based on an animation and an index */
 -(void) setDisplayFrame: (NSString*) animationName index:(int) frameIndex;
-/** returns an Animation given it's name */
--(Animation *)animationByName: (NSString*) animationName;
 @end
 
 #pragma mark Animation
@@ -71,7 +67,6 @@
 @interface Animation : NSObject &lt;CocosAnimation&gt;
 {
 	NSString *name;
-	int		tag;
 	float	delay;
 	NSMutableArray *frames;
 }
@@ -82,48 +77,30 @@
 @property (readwrite,assign) float delay;
 @property (readwrite,retain) NSMutableArray *frames;
 
-/** creates an Animation with name, delay and frames from image files
- @deprecated Use animationWithTag instead. Will be removed in v0.8
- */
-+(id) animationWithName: (NSString*) name delay:(float)delay images:image1,... NS_REQUIRES_NIL_TERMINATION __attribute__((deprecated));
-
-/** creates an Animation with tag, delay and frames from image files */
-+(id) animationWithTag:(int)tag delay:(float)delay images:image1,... NS_REQUIRES_NIL_TERMINATION;
+/** creates an Animation with name, delay and frames from image files */
++(id) animationWithName: (NSString*) name delay:(float)delay;
 
-/** creates an Animation with tag, delay */
-+(id) animationWithTag:(int)tag delay:(float)delay;
+/** creates an Animation with name, delay and frames from image files */
++(id) animationWithName: (NSString*) name delay:(float)delay images:image1,... NS_REQUIRES_NIL_TERMINATION;
 
 /** creates an Animation with name, delay and frames from Texture2D objects */
-+(id) animationWithName: (NSString*) name delay:(float)delay textures:tex1,... NS_REQUIRES_NIL_TERMINATION __attribute__((deprecated));
-
-/** creates an Animation with tag, delay and frames from Texture2D objects */
-+(id) animationWithTag:(int)tag delay:(float)delay textures:tex1,... NS_REQUIRES_NIL_TERMINATION;
++(id) animationWithName: (NSString*) name delay:(float)delay textures:tex1,... NS_REQUIRES_NIL_TERMINATION;
 
 /** initializes an Animation with name, delay and frames from Texture2D objects */
--(id) initWithName: (NSString*) name delay:(float)delay firstTexture:(Texture2D*)tex vaList:(va_list) args __attribute__((deprecated));
+-(id) initWithName: (NSString*) name delay:(float)delay firstTexture:(Texture2D*)tex vaList:(va_list) args;
 
-/** initializes an Animation with name, delay and frames from Texture2D objects */
--(id) initWithTag:(int)tag delay:(float)delay firstTexture:(Texture2D*)tex vaList:(va_list) args;
 
 
 /** initializes an Animation with name and delay
- @deprecated use initWithTag instead. Will be removed in v0.8
  */
--(id) initWithName: (NSString*) name delay:(float)delay __attribute__((deprecated));
-
-/** initializes an Animation with a tag and delay */
--(id) initWithTag:(int)tag delay:(float)delay;
+-(id) initWithName: (NSString*) name delay:(float)delay;
 
 /** initializes an Animation with name, delay and frames from image files
- @deprecated use initWithTag instead. Will be removed in v0.8
  */
 -(id) initWithName: (NSString*) name delay:(float)delay firstImage:(NSString*)filename vaList:(va_list) args;
 
-/** initializes an Animation with tag, delay and frames from image files */
--(id) initWithTag:(int)tag delay:(float)delay firstImage:(NSString*)filename vaList:(va_list) args;
-
 /** adds a frame to an Animation
- @deprecated use addFrameWithFilename. Will be removed in v0.8
+ @deprecated Use addFrameWithFilename instead. Will be removed in v0.8
  */
 -(void) addFrame: (NSString*) filename __attribute__((deprecated));
 
@@ -133,4 +110,3 @@
 /** adds a frame from a Texture2D object to an Animation */
 -(void) addFrameWithTexture: (Texture2D*) tex;
 @end
-</diff>
      <filename>cocos2d/Sprite.h</filename>
    </modified>
    <modified>
      <diff>@@ -123,21 +123,6 @@
 	animations = [[NSMutableDictionary dictionaryWithCapacity:2] retain];
 }
 
--(void) addAnimation: (Animation*) anim
-{
-	// lazy alloc
-	if( ! animations )
-		[self initAnimationDictionary];
-	
-	[animations setObject:anim forKey:[anim name]];
-}
-
--(Animation *)animationByName: (NSString*) animationName
-{
-	NSAssert( animationName != nil, @&quot;animationName parameter must be non nil&quot;);
-    return [animations objectForKey:animationName];
-}
-
 -(void) setDisplayFrame: (NSString*) animationName index:(int) frameIndex
 {
 	if( ! animations )
@@ -169,27 +154,37 @@
 {
 	return texture;
 }
+-(void) addAnimation: (id&lt;CocosAnimation&gt;) anim
+{
+	// lazy alloc
+	if( ! animations )
+		[self initAnimationDictionary];
+	
+	[animations setObject:anim forKey:[anim name]];
+}
+-(id&lt;CocosAnimation&gt;)animationByName: (NSString*) animationName
+{
+	NSAssert( animationName != nil, @&quot;animationName parameter must be non nil&quot;);
+    return [animations objectForKey:animationName];
+}
 @end
 
+#pragma mark -
 #pragma mark Animation
 
 @implementation Animation
 @synthesize name, delay, frames;
 
-+(id) animationWithTag:(int)t delay:(float)d
++(id) animationWithName:(NSString*)n delay:(float)d
 {
-	return [[[self alloc] initWithTag:t delay:d] autorelease];
+	return [[[self alloc] initWithName:n delay:d] autorelease];
 }
+
 -(id) initWithName: (NSString*) n delay:(float)d
 {
 	return [self initWithName:n delay:d firstImage:nil vaList:nil];
 }
 
--(id) initWithTag:(int)t delay:(float)d
-{
-	return [self initWithTag:t delay:d firstImage:nil vaList:nil];
-}
-
 -(void) dealloc
 {
 	CCLOG( @&quot;deallocing %@&quot;,self);
@@ -211,17 +206,6 @@
 	return s;
 }
 
-+(id) animationWithTag:(int)t delay:(float)delay images:image1,...
-{
-	va_list args;
-	va_start(args,image1);
-	
-	id s = [[[self alloc] initWithTag:t delay:delay firstImage:image1 vaList:args] autorelease];
-	
-	va_end(args);
-	return s;
-}
-
 -(id) initWithName: (NSString*) n delay:(float)d firstImage:(NSString*)image vaList: (va_list) args
 {
 	if( ! (self=[super init]) )
@@ -246,30 +230,6 @@
 	return self;
 }
 
--(id) initWithTag:(int)t delay:(float)d firstImage:(NSString*)image vaList: (va_list) args
-{
-	if( ! (self=[super init]) )
-		return nil;
-	
-	tag = t;
-	frames = [[NSMutableArray array] retain];
-	delay = d;
-	
-	if( image ) {
-		Texture2D *tex = [[TextureMgr sharedTextureMgr] addImage: image];
-		[frames addObject:tex];
-		
-		NSString *filename = va_arg(args, NSString*);
-		while(filename) {
-			tex = [[TextureMgr sharedTextureMgr] addImage: filename];
-			[frames addObject:tex];
-			
-			filename = va_arg(args, NSString*);
-		}	
-	}
-	return self;
-}
-
 -(void) addFrame: (NSString*) filename
 {
 	return [self addFrameWithFilename:filename];
@@ -292,16 +252,6 @@
 	va_end(args);
 	return s;
 }
-+(id) animationWithTag:(int)t delay:(float)delay textures:tex1,...
-{
-	va_list args;
-	va_start(args,tex1);
-	
-	id s = [[[self alloc] initWithTag:t delay:delay firstTexture:tex1 vaList:args] autorelease];
-	
-	va_end(args);
-	return s;
-}
 
 -(id) initWithName:(NSString*)n delay:(float)d firstTexture:(Texture2D*)tex vaList:(va_list)args
 {
@@ -325,28 +275,6 @@
 	return self;
 }
 
--(id) initWithTag:(int)t delay:(float)d firstTexture:(Texture2D*)tex vaList:(va_list)args
-{
-	self = [super init];
-	if( self ) {
-		tag = t;
-		frames = [[NSMutableArray array] retain];
-		delay = d;
-		
-		if( tex ) {
-			[frames addObject:tex];
-			
-			Texture2D *newTex = va_arg(args, Texture2D*);
-			while(newTex) {
-				[frames addObject:newTex];
-				
-				newTex = va_arg(args, Texture2D*);
-			}	
-		}
-	}
-	return self;
-}
-
 -(void) addFrameWithTexture: (Texture2D*) tex
 {
 	[frames addObject:tex];</diff>
      <filename>cocos2d/Sprite.m</filename>
    </modified>
    <modified>
      <diff>@@ -297,7 +297,7 @@ Class restartAction()
 	
 	[tamara setVisible:NO];
 	
-	id animation = [Animation animationWithTag:kTagAnimationDance delay:0.2f];
+	id animation = [Animation animationWithName:@&quot;dance&quot; delay:0.2f];
 	for( int i=1;i&lt;15;i++)
 		[animation addFrame: [NSString stringWithFormat:@&quot;grossini_dance_%02d.png&quot;, i]];
 	</diff>
      <filename>tests/SpritesDemo.m</filename>
    </modified>
    <modified>
      <diff>@@ -406,7 +406,7 @@ Class restartAction()
 		
 		AtlasSprite *sprite = [AtlasSprite spriteWithRect:CGRectMake(0, 0, 85, 121) spriteManager: mgr];
 		
-		AtlasAnimation *animation = [AtlasAnimation animationWithTag:kTagAnimation1 delay:0.2f];
+		AtlasAnimation *animation = [AtlasAnimation animationWithName:@&quot;dance&quot; delay:0.2f];
 		for(int i=0;i&lt;14;i++) {
 			int x= i % 5;
 			int y= i / 5;</diff>
      <filename>tests/TestAtlas.m</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>901f43723f1eb563d584c6d05af7cd3f0e711d49</id>
    </parent>
  </parents>
  <author>
    <name>ricardoquesada</name>
    <email>ricardoquesada@79afc9a6-2f50-0410-804d-6f1bdedaafc9</email>
  </author>
  <url>http://github.com/nullstyle/cocos2d-iphone/commit/600453e697f962ef0fcae493f0fcfbb96eeff067</url>
  <id>600453e697f962ef0fcae493f0fcfbb96eeff067</id>
  <committed-date>2009-03-13T10:42:40-07:00</committed-date>
  <authored-date>2009-03-13T10:42:40-07:00</authored-date>
  <message>improved animation API.
Sprite and AtlasSprite use the same protocol interface

git-svn-id: http://cocos2d-iphone.googlecode.com/svn/trunk@675 79afc9a6-2f50-0410-804d-6f1bdedaafc9</message>
  <tree>4073496303537f87159b0226db6aed442a57cb2a</tree>
  <committer>
    <name>ricardoquesada</name>
    <email>ricardoquesada@79afc9a6-2f50-0410-804d-6f1bdedaafc9</email>
  </committer>
</commit>
