• 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
Re: Tracking animation in multiple windows using NSTimer vs NSThread?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Tracking animation in multiple windows using NSTimer vs NSThread?


  • Subject: Re: Tracking animation in multiple windows using NSTimer vs NSThread?
  • From: "Kenneth C. Dyke" <email@hidden>
  • Date: Sun, 12 Aug 2001 14:02:48 -0700

On Sunday, August 12, 2001, at 12:20 PM, l.m.orchard wrote:


Hmm... looks like it's spending most of the time handling displayIfNeeded:

One thing I just did which seems to have cut the CPU usage by about 25% was to drive the TableListView updating with a timer reoccurring every 0.5 sec. So before, the TableListView was almost constantly reloading data because every window controller messaged to the main controller to update data every time a ball moved, which was every 0.05 sec. Now, I just 'sample' every 0.5 sec.

But the other thing is my method of animation. I have a custom view, with a circle drawn by an NSBezierPath, and moved to the current location via an NSAffineTransform (with translateXBy:yBy:). The circle is set up in initWithFrame. Every 0.05 sec, the animation timer calls a message which updates the position of the circle and calls [self setNeedsDisplay:YES]; And when called, drawRect: creates a new NSAffineTransform with the translation with which I then do [[circleTransform transformBezierPath:circleBezier] stroke];

This seems to be pretty heavyweight. So I'm thinking that I don't want to try animating anything like this. Is there a better way? Is this what NSQuickView is for?

If you don't need subpixel accurate positioning for each animation step (i.e., the circle is just moving by integer amounts each frame), you might consider caching the circle image in an NSImage and rendering that each frame rather than redoing the whole thing from scratch.

Or you could always use OpenGL. ;)

-Ken

Kenneth Dyke, email@hidden (personal), email@hidden (work)
Sr. Mad Scientist, MacOS X OpenGL Group, Apple Computer, Inc.
C++: The power, elegance and simplicity of a hand grenade.


References: 
 >Re: Tracking animation in multiple windows using NSTimer vs NSThread? (From: "l.m.orchard" <email@hidden>)

  • Prev by Date: Re: Tracking animation in multiple windows using NSTimer vs NSThread?
  • Next by Date: Localizable strings & attributes
  • Previous by thread: Re: Tracking animation in multiple windows using NSTimer vs NSThread?
  • Next by thread: Reading compiled applescript from file
  • Index(es):
    • Date
    • Thread