From cbee4846dc23bd9b3149dd656fc96c001a6149e0 Mon Sep 17 00:00:00 2001 From: exterlulz Date: Fri, 20 Aug 2010 19:29:08 +0200 Subject: [PATCH] change animationCount to property --- src/ScoreBubble.h | 9 ++++----- src/ScoreBubble.m | 39 +++++++++++++++++---------------------- 2 files changed, 21 insertions(+), 27 deletions(-) diff --git a/src/ScoreBubble.h b/src/ScoreBubble.h index 2fc30c2..3c3fc4a 100644 --- a/src/ScoreBubble.h +++ b/src/ScoreBubble.h @@ -28,13 +28,15 @@ { int value; NSPoint screenLocation; - int animationCount; + int _animationCount; NSImage *image; OpenGLSprite *sprite; } -+(ScoreBubble *)scoreWithValue:(int)value At:(NSPoint)loc Duration:(int)count; +@property int _animationCount; + ++ (ScoreBubble *)scoreWithValue:(int)value At:(NSPoint)loc Duration:(int)count; -(void)drawImage; -(void)drawSprite; @@ -42,9 +44,6 @@ -(id)initWithValue:(int)value At:(NSPoint)loc Duration:(int)count; -(int)animate; --(int)animationCount; --(void)setAnimationCount:(int)count; - -(int)value; -(NSImage *)image; diff --git a/src/ScoreBubble.m b/src/ScoreBubble.m index 109cd65..0358e48 100644 --- a/src/ScoreBubble.m +++ b/src/ScoreBubble.m @@ -31,9 +31,13 @@ NSMutableDictionary *stringAttributes; @implementation ScoreBubble -+(ScoreBubble *)scoreWithValue:(int)val At:(NSPoint)loc Duration:(int)count +@synthesize _animationCount; + ++ (ScoreBubble *)scoreWithValue:(int)val At:(NSPoint)loc Duration:(int)count { - return [[[[self class] alloc] initWithValue:val At:loc Duration:count] autorelease]; + ScoreBubble *scoreBubble = [[self alloc] initWithValue:val At:loc Duration:count]; + return [scoreBubble autorelease]; + // !!!: remove: return [[[self alloc] initWithValue:val At:loc Duration:count] autorelease]; } -(id)initWithValue:(int)val At:(NSPoint)loc Duration:(int)count @@ -54,7 +58,7 @@ NSMutableDictionary *stringAttributes; screenLocation= loc; screenLocation.x-=strsize.width/2; screenLocation.y-=strsize.height/2; - animationCount= count; + _animationCount= count; image= [[NSImage alloc] initWithSize:strsize]; [image lockFocus]; [stringAttributes setObject:[NSColor blackColor] forKey:NSForegroundColorAttributeName]; @@ -73,17 +77,17 @@ NSMutableDictionary *stringAttributes; return self; } -- (void) dealloc +- (void)dealloc { - [image release]; - [sprite release]; - - [super dealloc]; + [image release]; + [sprite release]; + + [super dealloc]; } -(void)drawImage { - float alpha= (float)animationCount/20; + float alpha= (float)_animationCount/20; if (alpha>1) { alpha= 1; } @@ -92,7 +96,7 @@ NSMutableDictionary *stringAttributes; -(void)drawSprite { - float alpha= (float)animationCount/20; + float alpha= (float)_animationCount/20; if (alpha>1) { alpha= 1; } @@ -104,20 +108,11 @@ NSMutableDictionary *stringAttributes; -(int)animate { - if (animationCount>0) { + if (_animationCount>0) { screenLocation.y++; - animationCount--; + _animationCount--; } - return animationCount; -} - --(int)animationCount -{ - return animationCount; -} --(void)setAnimationCount:(int)count -{ - animationCount= count; + return _animationCount; } -(int)value -- 2.11.4.GIT