Rob Sawyer
Rob Sawyer

Reputation: 2183

What's the most efficient way to create particles on the iPhone

I'm looking to create a snowfall effect on the iPhone and I'm looking for advice as to how to best implement this. I've planned to use a png image as the sprite.

Upvotes: 2

Views: 1374

Answers (3)

Rog
Rog

Reputation: 17170

If you have a series of keyframe animations as PNGs I woudl suggest using UIImageView's animation methods. UIImageView itself supports looping animations through a series of UIImages and you can use UIKit built in animation to animate the positions.

It is not going to be very efficient though. For high performance I think you are going to have to drop down to OpenGL which is a lot more learning.

I'd also suggest looking at Matt Gallagherts Quartzeroids. A game using CoreAnimation as the renderer.

Upvotes: 0

Chuck
Chuck

Reputation: 237060

This sounds like a good use for CALayers. Take a look at Scott Stevenson's NanoLife example. It's for the Mac rather than the iPhone, but it's a good example of using Core Animation for particles.

Upvotes: 5

Alex Wayne
Alex Wayne

Reputation: 187034

You could either dynamically create a bunch of UIImageViews and animate their positions in a loop (or possibly with core animation), or could draw the images to a CoreGraphics layer, and update that with a loop.

The third option would be an OpenGL solution, but I am pretty sure that you are not asking about that. Besides, OpenGL content over UIKit view will not perform very well.

Upvotes: 1

Related Questions