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

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

粒子動畫

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

粒子動畫中的關鍵概念是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];


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 乌苏市| 黔江区| 澳门| 鸡西市| 河北区| 瑞安市| 岐山县| 大英县| 东山县| 扎赉特旗| 义乌市| 双柏县| 左权县| 泰来县| 金川县| 曲周县| 含山县| 上栗县| 稷山县| 金塔县| 芒康县| 肃南| 安龙县| 江西省| 古田县| 喀喇| 星子县| 阳西县| 青浦区| 大姚县| 绩溪县| 淮滨县| 阿克苏市| 珲春市| 哈巴河县| 新晃| 瑞昌市| 武邑县| 兴隆县| 琼海市| 方正县|