• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Using NSAnimation
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Using NSAnimation


  • Subject: Using NSAnimation
  • From: Hrishikesh Muruk <email@hidden>
  • Date: Sun, 9 Nov 2008 18:13:33 +0530

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 (email@hidden)

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:
This email sent to email@hidden


  • Prev by Date: Re: Responder Chain & Multiple Windows
  • Next by Date: advice needed please
  • Previous by thread: Badged icons
  • Next by thread: Using NSAnimation
  • Index(es):
    • Date
    • Thread