iOS based on Caemitterlayer of snowflakes, fireworks, flames, love and other effects demo (turn)

Source: Internet
Author: User

 Reprinted from: http://blog.csdn.net/mad2man/article/details/16898369Category: Cocoa SDK2013-11-23 11:52 388 People read comments (0) favorite reports

Demo function: Based on Caemitterlayer snowflakes, fireworks, flames, love and other effects.

Demo Description: Based on the core animation particle emission system, particles are initialized with Caemittercell. The particles are drawn on the background layer box boundary

Demo screenshot:


Emitterposition: Launch position


Emittersize: The size of the transmitting source;

Emittermode: Launch mode

    1. NSString * Const kcaemitterlayerpoints;
    2. NSString * Const Kcaemitterlayeroutline;
    3. NSString * Const Kcaemitterlayersurface;
    4. NSString * Const Kcaemitterlayervolume;
Copy code Emittershape: The shape of the emitter source:
    1. NSString * Const Kcaemitterlayerpoint;
    2. NSString * Const Kcaemitterlayerline;
    3. NSString * Const Kcaemitterlayerrectangle;
    4. NSString * Const kcaemitterlayercuboid;
    5. NSString * Const kcaemitterlayercircle;
    6. NSString * Const Kcaemitterlayersphere;
Copy code Rendermode: Render Mode:
    1. NSString * Const kcaemitterlayerunordered;
    2. NSString * Const Kcaemitterlayeroldestfirst;
    3. NSString * Const Kcaemitterlayeroldestlast;
    4. NSString * Const Kcaemitterlayerbacktofront;
    5. NSString * Const kcaemitterlayeradditive;
Copy Code properties:

birthrate: particle generation coefficient, default 1.0;

Emittercells: An array of Caemittercell objects that are used to put particles on a layer;

Emitterdepth: Determining the depth of particle shape contact: emitter shape

Emitterzposition: the z-coordinate position of the transmitting source;

Lifetime: Particle life cycle

Preservesdepth: Not much clear (particles are flattened on the layer)


Scale: The scaling ratio of the particles:

Seed: Used to initialize seeds generated by random numbers

Spin: self-rotating speed

Velocity: particle velocity

Caemittercell


Caemittercell the particles emitted from the caemitterlayer; The emitter cell defines the direction of the particle emission.

Alpharange: The extent to which a particle's color alpha can change;

Alphaspeed: The speed at which particle transparency changes over the life cycle;

birthrate: Velocity multiplier factor for particle parameters; number of particles emitted per second

Bluerange: The color of a particle blue can change the range;

Bluespeed: The speed at which particle blue changes over the life cycle;

Color: The colors of the particles

Contents: is a Cgimageref object, both particles to show the picture;

Contentsrect: Should be drawn in the contents of the sub-rectangle:

Emissionlatitude: Angle of the z-axis direction of the launch

The direction of transmission of emissionlongitude:x-y plane

Emissionrange: The angle of the surrounding emission

Emittercells: particles emitted by a particle

Enabled: whether particles are rendered

Greenrange: The color of a particle green can change the range;

Greenspeed: The speed at which particle green changes over the life cycle;

Lifetime: Life cycle

Lifetimerange: Life cycle Range lifetime= lifetime (+/-) Lifetimerange

Magnificationfilter: Not so clear as to increase your size

Minificatonfilter: Reduce your size

Minificationfilterbias: Reducing the size factor

Name: the names of the particles

Redrange: The color of a particle red can change the range;

RedSpeed; The speed at which particle red changes over the life cycle;

Scale: Zoom:

Scalerange: scale scale range;

Scalespeed: Scale speed:

Spin: Sub-rotation angle

Spinrange: Sub-rotation angle range

Style: Not very clear:

Velocity: Velocity

Velocityrange: Speed Range

Xacceleration: Particle x-direction acceleration component

Yacceleration: Acceleration component in Y-direction of particles

Zacceleration: Acceleration component in Z-direction of particles

-(void) viewdidload

{

[Super Viewdidload];

Caemitterlayer *snowemitter = [Caemitterlayer layer];

Snowemitter.emitterposition = Cgpointmake (self.view.bounds.size.width/2.0,-30);

Snowemitter.emittersize = Cgsizemake (self.view.bounds.size.width, 0.0);

Snowemitter.emittermode = Kcaemitterlayeroutline;

Snowemitter.emittershape = Kcaemitterlayerline;

Caemittercell *snowflake = [Caemittercell Emittercell];

snowflake.birthrate = 2.0;

Snowflake.lifetime = 120.0;

snowflake.velocity =-10;

Snowflake.velocityrange = 10;

Snowflake.yacceleration = 2;

Snowflake.emissionrange = 0.5 * M_PI;

Snowflake.spinrange = 0.25 * M_PI;

Snowflake.contents = (ID) [[UIImage imagenamed:@ "Dazflake"] cgimage];

Snowflake.color = [[Uicolor colorwithred:0.600 green:0.658 blue:0.743 alpha:1.000] cgcolor];

Snowemitter.shadowopacity = 1.0;

Snowemitter.shadowradius = 0.0;

Snowemitter.shadowoffset = Cgsizemake (0.0, 1.0);

Snowemitter.shadowcolor = [[Uicolor blackcolor] cgcolor];

Snowemitter.emittercells = [Nsarray arraywithobject:snowflake];

[Self.view.layer Insertsublayer:snowemitter above:0];

Do any additional setup after loading the view.

}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.