Skip to content

Commit

Permalink
CCSpriteFrame: add -isEqual: method. Part of #9
Browse files Browse the repository at this point in the history
  • Loading branch information
psineur committed Jan 28, 2012
1 parent cacde93 commit 8acb48e
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions cocos2d/CCSpriteFrame.m
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,37 @@ -(void) setRectInPixels:(CGRect)rectInPixels
rect_ = CC_RECT_PIXELS_TO_POINTS(rectInPixels);
}

- (BOOL) isEqual:(id)object
{
CCSpriteFrame *other = (CCSpriteFrame *) object;
if (![other isKindOfClass:[CCSpriteFrame class]])
return NO;

if (self.name != other.name)
return NO;

// Texture's are equal pointers, or they both have equal, non-nil keys.
if (self.texture != other.texture && !( self.texture.key && self.texture.key == other.texture.key) )
return NO;

if (!CGRectEqualToRect(self.rect, other.rect))
return NO;

if (!CGRectEqualToRect(self.rectInPixels, other.rectInPixels))
return NO;

if (self.rotated != other.rotated)
return NO;

if (!CGPointEqualToPoint(self.offsetInPixels, other.offsetInPixels))
return NO;

if (!CGSizeEqualToSize(self.originalSizeInPixels, other.originalSizeInPixels))
return NO;

return YES;
}

#pragma mark AutoMagicCoding Support

+ (BOOL) AMCEnabled
Expand Down

0 comments on commit 8acb48e

Please sign in to comment.