问题
All is in the question, I've worked enough with cocos2d to say it's a great library but today I only wanna use particle system in a total UIKit project. As long as I know, unfortunately, I have to implement one with OpenGL. Any suggestions ?
回答1:
You can use Core Animation and CAReplicatorLayer to generate particle systems without having to drop down to OpenGL ES. Joe Ricioppo's "To 1e100f And Beyond with CAReplicatorLayer" gives an introduction to how to use this class. Also, Apple has their ReplicatorDemo sample application, which I ported to the iPad.
On the Mac, there's also the CAEmitterLayer, which became available in iOS as of 5.0. Apple's sample applications for this include Fire, which shows off fire and smoke effects, and Fireworks, which simulates a fireworks display.
回答2:
For a UIKit-only project you could use Particle Playground (Mac App Store Link) to configure your emitter on your mac in a simulator and the export it as code ready for integration in your project. PP is quite similar to Particle Designer as mentioned by matt.
If you don't want to use a helper so you can dive deeper into the CAEmitter(Layer/Cell) then I would recommend reading this tutorial on Ray Wenderlich's site or this article on Arg! Team's blog. They have helped me a lot in configuring my own emitters.
Full disclosure: I am the developer of Particle Playground. I grew tired of the whole tweak-recompile-observe-loop and developed PP in my spare time.
回答3:
Note that CAEmitterLayer was added in iOS 5. That makes particle effects much easier.
I haven't used it yet, but I have seen examples that do. I'm not sure how hard Apple's fire sample would be to port to iOS 5. I might just give it a try
回答4:
I too, find designing particles in UIKit a challenge so I created an app for it. Used it to create various particles in my games now. So easy! It is a iDevice app so you can play with particles while in a bus or at a mall and immediately export out the codes.
If anybody is interested: http://iapps.emirbytes.com/particlex/index.html
回答5:
In UIKit you build particle systems by using the QuartzCore framework. For a complete example read this post:
http://www.raywenderlich.com/6063/uikit-particle-systems-in-ios-5-tutorial
回答6:
You should use CAEmitterLayer
Here are some tutorials
- https://www.hackingwithswift.com/read/37/5/creating-a-particle-system-using-caemitterlayer
- https://medium.com/call-voicy/comets-animating-particles-in-swift-3431a7f1b250
Here are some ways to playground it
- Here is how to playground using SpriteKit http://www.techotopia.com/index.php/An_iOS_8_Sprite_Kit_Particle_Emitter_Tutorial
- Xcode 8+ also includes Playground, you can create a Playground to play around with it https://github.com/onmyway133/ParticlePlayground
回答7:
You should also consider Particle Emitter (http://particledesigner.71squared.com/) which was designed to be used as a cocos2d plug-in.
A tutorial is provided here: http://www.71squared.com/2009/05/iphone-game-programming-tutorial-8-particle-emitter/
来源:https://stackoverflow.com/questions/4784994/what-is-the-easiest-way-to-implement-particle-system-without-opengl-nor-cocos2d