In your original code, you never allocated a new instance of BubbleAnimation
, and that's why it worked fine.
You have an object in the XIB file which is the BubbleAnimation object, and that's all fine, but the problem is that you're allocating a new instance of BubbleAnimation instead of using the one you have in your revised code.
Even if you were to use the one you have, you'd have to change the init method, since the system will call initWithCoder:
, not initWithMood:
.
The best thing is most likely to change the init function to something else, e.g. a setMood:
, which modifies the image view. Then you re-use the same image view every time.
Then you'd just set it up using something like...
[bubbleAnimation setMood:character.mood];
bubbleAnimation.animationDuration = 0.5;
bubbleAnimation.animationRepeatCount = 5;
[bubbleAnimation startAnimating];
Kalle
2010-07-06 09:54:21