-(
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
);
float
gas=
.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
.1
f;
fire.yAcceleration = -
200
;
fire.ScaleSpeed =
0
.3
f;
fire.color=[[
UIColor
colorWithRed:
0
.8
green:
0
.4
blue:
0
.2
alpha:
0
.1
]
CGColor
];
fire.contents = (
id
)[[
UIImage
imageNamed:
@"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
.1
f;
smoke.AlphaSpeed = -
0
.22
f;
smoke.ScaleSpeed =
0
.7
f;
smoke.color=[[
UIColor
colorWithRed:
1
green:
1
blue:
1
alpha:
0
.3
*gas]
CGColor
];
smoke.contents = (
id
)[[
UIImage
imageNamed:
@"smoke.png"
]
CGImage
];
[smoke setName:
@"smoke"
];
fireEmitter.emitterCells = [
NSArray
arrayWithObjects: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.
|
CAEmitterCell
最新推荐文章于 2024-08-13 10:01:57 发布