国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

粒子動畫

2019-11-09 17:18:21
字體:
來源:轉載
供稿:網友

粒子動畫中的關鍵概念是CAEmitterLayer和 CAEmitterCell,其中CAEmitterLayer是發射源,CAEmitterCell是發射出去的粒子.

其余的一些屬性官網或者百度都可以知道.

另附代碼如下

    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(self.view.bounds.size.width / 2 ,                                                            self.view.bounds.size.height, 200, 200)];    view.backgroundColor = [UIColor redColor];    view.layer.cornerRadius = 50;    [self.view addSubview:view];    //create particle emmitter layer    //CAEmitterLayer負責發射粒子(粒子也可以發射粒子)    CAEmitterLayer *emitter = [CAEmitterLayer layer];    emitter.frame = view.bounds;    //決定粒子發射形狀的中心點    emitter.emitterPosition = CGPointMake(100, 100);    emitter.emitterZPosition = 3.0;    emitter.emitterShape = kCAEmitterLayerPoints;//發射器形狀    emitter.emitterMode = kCAEmitterLayerPoints;//3d圓形的體積內發射    emitter.PReservesDepth = YES; //是否開啟三維空間模式    emitter.emitterDepth = 2.0;//發射器的深度,有時可能會產生立體效果    emitter.spin = 5;//粒子的旋轉角度    [view.layer addSublayer:emitter];    emitter.renderMode = kCAEmitterLayerAdditive;//渲染模式    //emitter.emitterPosition = CGPointMake(emitter.frame.size.width /2.0, emitter.frame.size.height / 2.0);    //creat a particle template]    CAEmitterCell *cell = [[CAEmitterCell alloc] init];    cell.contents = (__bridge id _Nullable)([UIImage imageNamed:@"d00"].CGImage);    cell.birthRate = 15.0;    cell.lifetime = 5.0;    cell.enabled = YES;//是否打開粒子的渲染效果    //  cell.color = [UIColor colorWithRed:1 green:0.5 blue:0.1 alpha:1.0].CGColor;    cell.alphaspeed = -0.4;    cell.velocity = 50; //粒子的速度    cell.velocityRange = 70;//粒子的速度范圍    cell.emissionRange = M_PI * 2.0;    //creat a particle template]    CAEmitterCell *cell2 = [[CAEmitterCell alloc] init];    cell2.contents = (__bridge id _Nullable)([UIImage imageNamed:@"d01"].CGImage);    cell2.birthRate = 15.0;    cell2.lifetime = 5.0;    cell2.color = [UIColor colorWithRed:1 green:0.5 blue:0.1 alpha:1.0].CGColor;    cell2.alphaSpeed = -0.4;    cell2.velocity = 50;    cell2.velocityRange = 50;    cell2.emissionRange = M_PI * 2.0;    //add pareticle template to emitter    emitter.emitterCells = @[cell,cell2];


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 云南省| 呼图壁县| 任丘市| 广饶县| 济阳县| 泰来县| 慈溪市| 蒙山县| 曲阜市| 任丘市| 孙吴县| 西宁市| 祥云县| 永平县| 玉林市| 凤城市| 鄯善县| 钟山县| 花垣县| 宁德市| 淳化县| 漳州市| 津南区| 突泉县| 红安县| 共和县| 陈巴尔虎旗| 南岸区| 东光县| 涞源县| 海伦市| 滦平县| 会泽县| 望谟县| 三河市| 珠海市| 彩票| 永丰县| 台山市| 遂昌县| 浦县|