Re: CoreAnimation with and manual animation...
Re: CoreAnimation with and manual animation...
- Subject: Re: CoreAnimation with and manual animation...
- From: Jesse Grosjean <email@hidden>
- Date: Tue, 1 Apr 2008 18:54:21 -0400
Jens,
Thanks for your reply.
What I'm doing now is something like this:
[CATransaction begin];
[CATransaction setValue:[NSNumber numberWithFloat:0]
forKey:kCATransactionAnimationDuration];
for (CALayer *each in [rootLayer.sublayers copy]) {
[each step]; // calculate and assign self new position
}
[CATransaction commit];
I've also looked at the physics engine stuff, looks like great fun,
but this project is actually super simple so I probably won't bother
with including a physics engine for now.
Jesse
On Apr 1, 2008, at 6:17 PM, Jens Alfke wrote:
On 1 Apr '08, at 10:44 AM, Jesse Grosjean wrote:
n my app it seems like it would be simpler to just setup a timer
and just directly update the ships position based on it's velocity
for each time interval from my timer. I'd still want to use the
built in core animation animations for other properties such as
transparency, filters, etc. But for layer position it seems like it
would be easiest to control that directly...
You're right. Last year I was fooling around with hooking CA up to a
2D physics engine, and I just let the engine tell me where and when
to position the objects, and set their position properties
accordingly.
For best results, disable animations for this, otherwise CA will try
to interpolate positions and things won't move correctly. I was
doing this by using a CATransaction to disable all animations, but I
think in hindsight it might be better just to to adjust the layers'
animation dictionaries to clear out the animation for the "position"
key.
(Using an existing physics engine is a great way to go, if you want
to do this. I was using Box2D, but there's another similar one
called Chipmunk. The math for this stuff gets really hairy — I've
just started reading "Physics For Game Developers", and it's
fascinating but I'm so glad I don't have to implement that myself!)
—Jens
_______________________________________________
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