I have a basic question about using NSAnimation. Here is what I am trying to do: My program shows a custom view and I want to animate an NSImage within that custom view. When the mouse is clicked within the program I want to move (animate) the image to a new point in the window.

I have subclassed NSAnimation into MyAnim and I have overloaded the method "-(void)setCurrentProgress:(NSAnimationProgress)progress". My program is organized in this fashion.

I have a custom view class MyView which has pointers to my data objects (an NSImage in this case) and my animation object myAnim. It also has a pointer to my custom view object MyView.

On a mouse click I send the message
[myAnim startAnimation];

@interface MyView : NSView {
        
        NSImage *myObj;
        MyAnim *myAnim;
}


I want the animation to begin when the mouse is clicked so I have overloaded the "-mouseDown" method to call [myAnim startAnimation];. I plan to animate my image by changing its position from within - setCurrentProgress. My problem - how do I access myObj from within the method -setCurrentProgress (which is inside MyAnim). I could do something like:

(in file MyAnim.m)
-(void)setCurrentProgress:(NSAnimationProgress)progress {
        NSImage * tmpImg = [super valueForKey:@"myObj"];
}

But it looks a little bit like a hack.

My questions:
1. Is there a better way to access myObj from MyAnim?
2. Once I change the position of myObj how do I get the view to redraw the image?

Hrishi

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to