- 最后登录
- 2013-9-29
- 注册时间
- 2012-8-20
- 阅读权限
- 90
- 积分
- 6371
- 纳金币
- 6372
- 精华
- 0
|
最终效果图:
一 思路
我们在玩游戏的时候,经常能看到一些粒子特效被绑定在武器上,装备上。其实就是将粒子定位在某个对象上。在这篇教程中,我们把火焰粒子绑定在阿宝的两个手掌的骨骼上。
二 准备
现在我们需要一个火焰粒子特效和一个阿宝的模型。
粒子特效我直接拿了yblunan的东西,地址如下:火焰粒子
阿宝的模型在最后附件中提供,值得注意的是,模型中我将左右手掌需要绑定的骨骼命名为fire,fire2。
接下来先看看完整代码,然后逐步讲解。
package
2 {
3 import base.Base;
4
5 import components.BoneController;
6
7 import flare.basic.Scene3D;
8 import flare.basic.Viewer3D;
9 import flare.core.Camera3D;
10 import flare.core.Mesh3D;
11 import flare.core.ParticleEmiter3D;
12 import flare.core.Pivot3D;
13 import flare.core.Texture3D;
14 import flare.materials.ParticleMaterial3D;
15 import flare.materials.filters.ColorParticleFilter;
16 import flare.materials.filters.TextureFilter;
17
18 import flash.display.Bitmap;
19 import flash.events.Event;
20
21 [SWF(width=800,height=600)]
22 public class TheBao extends Base
23 {
24 [Embed(source="fire.png")]
25 private var Fire:Class;
26
27 [Embed(source="abao.f3d",mimeType="application/octet-stream")]
28 private var ABao:Class;
29 private var scene:Scene3D;
30 private var baoivot3D;
31 public function TheBao(info:String="粒子绑定骨骼")
32 {
33 super(info);
34 scene=new Viewer3D(this);
35 scene.camera=new Camera3D();
36 scene.camera.z=-250;
37 scene.camera.y=100;
38 //scene.frameRate=10;
39 scene.addEventListener(Scene3D.COMPLETE_EVENT,onCom);
40
41 bao=scene.addChildFromFile(new ABao);
42
43 }
44 private function onCom(e:Event):void
45 {
46
47 var fire:Bitmap=new Fire();
48 var pmarticleMaterial3D=new ParticleMaterial3D();
49 pm.filters.push(new TextureFilter(new Texture3D(fire.bitmapData)));
50 pm.filters.push(new ColorParticleFilter([0xffffff,0xffff00,0xff0000,0x000000],[1,.5,.2,0]));
51 pm.build();
52
53 var fireEmiterarticleEmiter3D=new ParticleEmiter3D("",pm,new FireParticle());
54 fireEmiter.particlesLife=20;
55 fireEmiter.emitParticlesPerFrame=50;
56 fireEmiter.rotateX(90);
57 fireEmiter.layer=10;
58
59 var fireEmiter2articleEmiter3D=new ParticleEmiter3D("",pm,new FireParticle());
60 fireEmiter2.particlesLife=20;
61 fireEmiter2.emitParticlesPerFrame=50;
62 fireEmiter2.rotateX(90);
63 fireEmiter2.layer=11;
64
65 var baoMesh:Mesh3D=bao.getChildByName("bao") as Mesh3D;
66 fireEmiter.addComponent(new BoneController(baoMesh,"fire"));
67 fireEmiter2.addComponent(new BoneController(baoMesh,"fire2"));
68 scene.addChild(fireEmiter);
69 scene.addChild(fireEmiter2);
70 }
71 }
72 }
附件: |
|