简体   繁体   中英

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.

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.

You could either dynamically create a bunch of UIImageView s 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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM