This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
extensions:sxparticlesystem [2013/09/29 18:07] – [Changelog] daniel | extensions:sxparticlesystem [2015/09/14 11:14] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ~~NOTOC~~ | ||
+ | ====== SXParticleSystem ====== | ||
+ | |||
+ | ---- dataentry extension ---- | ||
+ | type : extension #or ' | ||
+ | author_mail | ||
+ | description | ||
+ | lastupdate_dt : 2011-08-26 #the date you created the extension | ||
+ | compatible | ||
+ | depends | ||
+ | tags : particle, particle-system, | ||
+ | homepage_url | ||
+ | download_url | ||
+ | ---- | ||
+ | |||
+ | ===== Overview ===== | ||
+ | |||
+ | {{ : | ||
+ | |||
+ | This class provides an easy way to display particle systems. | ||
+ | |||
+ | Particle Systems can be used to create special effects like explosions, smoke, snow, fire, etc. The system is controlled by a configuration file in the format that is created by [[http:// | ||
+ | |||
+ | In the '' | ||
+ | |||
+ | <note info> | ||
+ | If you're looking for a version of the particle system \\ | ||
+ | that runs with Sparrow 1.x, you can still get it [[https:// | ||
+ | </ | ||
+ | ===== Sample Project ===== | ||
+ | |||
+ | The '' | ||
+ | |||
+ | The project contains 4 sample configurations. Switch between configurations in '' | ||
+ | |||
+ | <code objc> | ||
+ | mParticleSystem = [[SXParticleSystem alloc] initWithContentsOfFile: | ||
+ | </ | ||
+ | | ||
+ | The following sample configurations are provided: | ||
+ | |||
+ | * drugs.pex | ||
+ | * fire.pex | ||
+ | * sun.pex | ||
+ | * waterfall.pex | ||
+ | |||
+ | ===== Usage ===== | ||
+ | |||
+ | This is all you have to do to create a particle system. The class '' | ||
+ | |||
+ | <code objc> | ||
+ | // create particle system | ||
+ | SXParticleSystem *ps = [[SXParticleSystem alloc] initWithContentsOfFile: | ||
+ | ps.x = 160.0f; | ||
+ | ps.y = 240.0f; | ||
+ | | ||
+ | // add it to the stage and the juggler | ||
+ | [self addChild: | ||
+ | [self.juggler addObject: | ||
+ | // [[SPStage mainStage].juggler addObject: | ||
+ | [ps release]; | ||
+ | |||
+ | // change position where particles are emitted | ||
+ | ps.emitterX = 20.0f; | ||
+ | ps.emitterY = 40.0f; | ||
+ | |||
+ | // start emitting particles | ||
+ | [ps start]; | ||
+ | |||
+ | // emit particles for two seconds, then stop | ||
+ | [ps startBurst: | ||
+ | | ||
+ | // stop emitting particles | ||
+ | [ps stop]; | ||
+ | |||
+ | // or get notified when all particles are gone | ||
+ | [ps addEventListenerForType: | ||
+ | { | ||
+ | NSLog(@" | ||
+ | }]; | ||
+ | </ | ||
+ | |||
+ | ===== Remarks ===== | ||
+ | |||
+ | === Not touchable === | ||
+ | |||
+ | The particle system' | ||
+ | |||
+ | === Performance on Retina displays === | ||
+ | |||
+ | On devices with a retina display (iPhone 4), the performance can suffer when there are a lot of particles on the screen. That's because four times as many pixels have to be rendered for each and every particle! | ||
+ | |||
+ | A simple workaround: store the particle texture twice in the same resolution. Once as " | ||
+ | |||
+ | === Particle Designer: emitter location ignored === | ||
+ | |||
+ | The emitter location you can set in the Particle Designer is ignored, too. To move the particle system around, change the '' | ||
+ | |||
+ | === Particle Designer: systems are upside-down === | ||
+ | |||
+ | Furthermore, | ||
+ | |||
+ | ===== Changelog ===== | ||
+ | |||
+ | * // | ||
+ | * // | ||
+ | * Reacting to changes in scale ('' | ||
+ | * Better handling of low framerates | ||
+ | * Added '' | ||
+ | * Added '' | ||
+ | * // | ||
+ | * // | ||
+ | * removed obsolete field | ||
+ | * modernized project (Xcode 4.1) | ||
+ | * // | ||
+ | * added properties for all settings | ||
+ | * added copy method | ||
+ | * added new init method that takes just a texture | ||
+ | * // | ||
+ | * // | ||
+ | * // | ||
+ | * // | ||
+ | * // | ||
+ | ===== Source Code ===== | ||
+ | |||
+ | You can browse the source code of the particle system on its [[https:// | ||
+ | |||
+ | ===== Discussion ===== | ||
+ | |||
+ | * Can you please give an example or discuss how we could change it from being a Point Sprite as to enable rotations? | ||
+ | * That requires to create 4 vertices (instead of one) for each particle, and then draw the particle with 2 triangles made up of those vertices. I plan to add that feature to the PS with the release of Sparrow 2.0, though. | ||
+ | * Could you please show how (and why) the copy method works? | ||
+ | * To copy the Particle System, just call the copy method! It creates a duplicate with the exact same settings. <code objc> | ||
+ | SXParticleSystem *psCopy = [ps copy]; | ||
+ | </ | ||
+ | * The XCode 5 beta has a particle system editor in it. Are there any plans to use that format with this extension? |