2008 04 01Core Animation Starfield
It looks better when moving ! :)
After learning that core animation doesn't like a root layer with a perspective transform, this sample sets up the perspective transform on a container layer, and stores the CATextLayer
layers there. Works pretty well this time !
This uses preferredFrameSize
to set the CATextLayer
bounds, animates zPosition
with CABasicAnimation
and opacity
with CAKeyframeAnimation
to get a smooth transition from invisible, visible, invisible.
Coordinates
As we're going 3d, we don't work with (x,y) beetween ([0…frame width], [0 … frame height]) but with centered coordinates : [-width…width, -height…height]. This means our container layer needs to be centered in the view, or the 3d objects will appear to spring from the bottom left corner.
Issues
- hit testing a layer doesn't work reliably.
- the main layer is manually centered. Couldn't wrap my head around constraints.
- how do you use Cocoa controls on a HUD window ? They don't look that good …
Core Animation
- CocoaNav a Cocoa Class Browser using Core Animation
- Core Animation Starfield Core Animation sample using 3D layers
CoreAnimationStarfield.zip - Core Animation culling problems Don't setup a projection transform on the root layer !
- Threaded Core Animation while on the main thread, update your display with
[CATransaction commit]
CoreAnimationUpdateOnMainThread.zip - Core Animation Bindings binding Cocoa objects to
CALayer
s
Core Animation Bindings.zip - Core Animation Phantom Fade seeing ghosting ? Use two transaction to create and animate your objects
CoreAnimationPhantomFade.zip - Photoshop-like compositing with Core Animation
Blending Modes.zip
Woops ! Maybe I should have Bloom disabled by default. But it's so much prettier ... :)
Very nice example ! Thanks a lot. Apple should provide that as sample code for CATextLayer.
Nice code!
Runs like a dog on Macbook (1st gen) until you turn bloom filter off. Then runs really smoothly.
Subscribed!