Data-Driven Animation
Data-Driven Animation
- Subject: Data-Driven Animation
- From: Rippit the Ogg Frog <email@hidden>
- Date: Sat, 12 Dec 2009 01:02:29 -0800
I'm working on what is now a Mac OS X prototype, that I'll be porting to
the iPhone once I have a better architecture in place.
Please forgive me for being vague about the precise nature of my
product. :-D
I need to better understand how to architect a 2-D animation in my app.
I'm happy to Read The Fine Manual if you can give me some pointers as
to where to look.
I have a data model that is represented in graphical form on the screen.
The data model updates many times per second. Each time the data
model updates, I'd like to update the screen.
What I do now I'm certain isn't correct. Whenever the data model has
changed, the view object that holds the graphical representation calls:
[self setNeedsDisplay: YES];
In the drawRect method, I convert the data model into its graphical
representation.
I'd like the data model to update as fast as it can; sometimes there
will be several updates to the data model in between screen refreshes.
That would actually be OK, if I don't see some of the steps in between
refreshes; I just want whatever I do see to be completely consistent.
A problem I see is that when drawRect is called, the data model might be
part-way through updating. So the screen would have an inconsistent
graphic drawn on it.
I think what might work better is to have two off-screen graphics
buffers. One of them will be updated according to the model, then only
when that buffer is complete, a pointer will be switched that makes it
the "current" graphics buffer, that is used by drawRect.
Having two graphics buffers would enable me to draw into one without
fear of screwing up the on-screen image, while the other has a
completely consistent image.
The "current" buffer would be copied to the screen by whatever Cocoa
uses instead of the old Classic CopyBits.
I know that Quartz has built-in double buffering. Could that help me
somehow?
Thanks for any advice you can give me.
Mike Crawford
email@hidden
http://www.oggfrog.com
_______________________________________________
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