views:

26

answers:

2

I'm wondering how to get some nice sprite-animations on OSX - like the UIImageView provides for the iPhoneOS. NSImageView cant... but how can I solve this?

A: 

If you want to do animation, Core Animation seems like a reasonable choice. (Specifically see the section on providing key frames.)

Chuck
I want a SPRITE ANIMATION not moving something around... ;)
meilo
@meilo: The purpose of Core Animation is not just "moving something around." I added a link directly to a part that talks about UIImageView-like animations.
Chuck
Ah ok :P didn't know this :) thx!
meilo
A: 

There is no built in equivalent, but it should be fairly easy to build your own.

A UIImage is a thin wrapper around a CGImageRef, where an NSImage is a fairly complex class that is decoupled from the actual drawing of an image. UIImageView takes an array of UIImages and swaps them out on a timer. You can create your own thin wrapper for CGImage, or use CGImages directly, and draw the sequentially on a timer in your custom NSView.

Alternately you can try to use an animated gif. NSImageView will animate an image that has a sequence of frames. It does not accept an array of images to treat as frames. If you were to implement your own NSImage class, you could probably use NSImageView to animate it, but I think a custom NSView would be easier.

drawnonward