CAEmitterCell

来源:互联网 发布:课程表编排软件 编辑:程序博客网 时间:2024/05/08 22:22
-(void)awakeFromNib
{
 CAEmitterLayer* fireEmitter = (CAEmitterLayer*)self.layer; ;
    fireEmitter.emitterPosition = CGPointMake(self.bounds.size.width/2,self.bounds.size.height);
    fireEmitter.emitterMode =   kCAEmitterLayerOutline;
    fireEmitter.emitterShape = kCAEmitterLayerLine;
 
    fireEmitter.emitterSize = CGSizeMake(self.bounds.size.width/5,self.bounds.size.width/5);
 
    floatgas=.7;
    // Create the fire emitter cell
    CAEmitterCell *fire = [CAEmitterCell emitterCell];
    fire.emissionLongitude = M_PI;
    fire.emissionLatitude = -M_PI/2;
    fire.BirthRate = 0;//100*gas;
    fire.lifetime=gas;
    fire.lifetimeRange=gas*0.35;
    fire.Velocity = 80;
    fire.VelocityRange = 21;
    fire.EmissionRange = 1.1f;
    fire.yAcceleration = -200;
    fire.ScaleSpeed = 0.3f;
    fire.color=[[UIColorcolorWithRed:0.8green:0.4blue:0.2alpha:0.1]CGColor];
    fire.contents = (id)[[UIImageimageNamed:@"fire.png"]CGImage];
    [fire setName:@"fire"];
 
    CAEmitterCell *smoke = [CAEmitterCell emitterCell];
    smoke.BirthRate = 0;//11;
    smoke.emissionLongitude = -M_PI;
    smoke.emissionLatitude=-M_PI;
    smoke.lifetime = gas*4;
    smoke.Velocity = 40;
    smoke.VelocityRange = 20;
    smoke.emissionRange = M_PI/4;
    smoke.Spin = 1;
    smoke.SpinRange = 6;
    smoke.yAcceleration = -160;
    smoke.Scale = 0.1f;
    smoke.AlphaSpeed = -0.22f;
    smoke.ScaleSpeed = 0.7f;
    smoke.color=[[UIColorcolorWithRed:1green:1blue:1alpha:0.3*gas]CGColor];
 
    smoke.contents = (id)[[UIImageimageNamed:@"smoke.png"]CGImage];
    [smoke setName:@"smoke"];
 
    fireEmitter.emitterCells = [NSArrayarrayWithObjects:smoke,fire,nil];
}


You can download Hanukkah Menorah on the app store now for FREE. It supports both the iPad and iPhone. It also has some In-App-Purchases to change from the default menorah.
原创粉丝点击