Create incredible particle effects with Partigen 2

Do you remember Partigen?

Andrew Fitzgerald from Desuade released the new version, of his amazing particle effects engine: Partigen 2.

Featuring over 120 exclusive preset effects, Partigen 2 is the first and only extension for Flash that let’s you to create complex particle effects in just a click.

The list of features is huge, so I am listing the ones I found most interesting:

You can read the full list of features here

The documentation is awesome, the best I’ve seen so far in a product like this one. You can access the full API documentation, and from this link you can access a 42 minutes long video covering the entire Partigen 2 component, and you can create beautiful effects using the component in less than a minute.

Anyway, we’re not here to talk about the component, but to test the AS3 API.

Playing with AS3 API

In this example, I am going to create a particle effect with the user interface provided in the component, then I’ll export it with XML and finally add it “on the fly” to the Box2D car example.

Playing with the presets is easy and fun, and once you’re done, just press “Copy to XML” to have the XML copied into your dashboard

Then, since we don’t want external files in our game, this is the code we need:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
package {
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.KeyboardEvent;
	//
	import Box2D.Dynamics.*;
	import Box2D.Collision.*;
	import Box2D.Collision.Shapes.*;
	import Box2D.Common.Math.*;
	import Box2D.Dynamics.Joints.*;
	// partigen libraries
	import com.desuade.partigen.emitters.*;
	import com.desuade.partigen.renderers.*;
	public class partigen extends Sprite {
		public var world:b2World;
		public var car_body:b2Body;
		public var front_wheel:b2Body;
		public var rear_wheel:b2Body;
		public var front_motor:b2RevoluteJointDef = new b2RevoluteJointDef();
		public var rear_motor:b2RevoluteJointDef = new b2RevoluteJointDef();
		public var fixtureDef:b2FixtureDef = new b2FixtureDef();
		public var rear_motor_added:b2RevoluteJoint;
		public var front_motor_added:b2RevoluteJoint;
		// partigen variables
		public var the_particle:particle_mc = new particle_mc();
		var particle_emitter:Emitter = new Emitter();
		public function partigen() {
			world=new b2World(new b2Vec2(0,10.0),true);
			debug_draw();
			var body:b2Body;
			var bodyDef:b2BodyDef= new b2BodyDef();
			var boxDef:b2PolygonShape = new b2PolygonShape();
			var circleDef:b2CircleShape=new b2CircleShape(20/30);
			var revoluteJointDef:b2RevoluteJointDef = new b2RevoluteJointDef();
			bodyDef.position.Set(250/30, 200/30);
			boxDef.SetAsBox(600/30, 20/30);
			fixtureDef.shape=boxDef;
			fixtureDef.friction=1;
			fixtureDef.density=1;
			body=world.CreateBody(bodyDef);
			body.CreateFixture(fixtureDef);
			bodyDef.position.Set(0/30, 200/30);
			boxDef.SetAsBox(50/30, 50/30);
			fixtureDef.shape=boxDef;
			fixtureDef.friction=1;
			fixtureDef.density=1;
			body=world.CreateBody(bodyDef);
			body.CreateFixture(fixtureDef);
			bodyDef.position.Set(500/30, 200/30);
			boxDef.SetAsBox(50/30, 50/30);
			fixtureDef.shape=boxDef;
			fixtureDef.friction=1;
			fixtureDef.density=1;
			body=world.CreateBody(bodyDef);
			body.CreateFixture(fixtureDef);
			bodyDef.position.Set(250/30, 90/30);
			bodyDef.type=b2Body.b2_dynamicBody;
			bodyDef.userData = new Sprite();
			boxDef.SetAsBox(50/30, 10/30);
			fixtureDef.shape=boxDef;
			fixtureDef.density=1;
			fixtureDef.friction=1;
			fixtureDef.restitution=0.1;
			car_body=world.CreateBody(bodyDef);
			car_body.CreateFixture(fixtureDef);
			fixtureDef.density=1;
			fixtureDef.friction=5;
			fixtureDef.density=0.1;
			fixtureDef.shape=circleDef;
			bodyDef.allowSleep=false;
			bodyDef.position.Set(car_body.GetWorldCenter().x + 40/30, car_body.GetWorldCenter().y);
			front_wheel=world.CreateBody(bodyDef);
			front_wheel.CreateFixture(fixtureDef);
			bodyDef.position.Set(car_body.GetWorldCenter().x - 40/30, car_body.GetWorldCenter().y);
			rear_wheel=world.CreateBody(bodyDef);
			rear_wheel.CreateFixture(fixtureDef);
			front_motor.enableMotor=true;
			front_motor.maxMotorTorque=10;
			front_motor.Initialize(car_body, front_wheel, front_wheel.GetWorldCenter());
			front_motor_added=world.CreateJoint(front_motor) as b2RevoluteJoint;
			rear_motor.enableMotor=true;
			rear_motor.maxMotorTorque=1;
			rear_motor.Initialize(car_body, rear_wheel, rear_wheel.GetWorldCenter());
			rear_motor_added=world.CreateJoint(rear_motor) as b2RevoluteJoint;
			addEventListener(Event.ENTER_FRAME, update);
			stage.addEventListener(KeyboardEvent.KEY_DOWN, key_down);
			// partigen code
			var particle_container:Sprite = new Sprite();
			addChild(particle_container);
			var particle_renderer:Renderer=new StandardRenderer(particle_container,'top');
			particle_emitter.renderer=particle_renderer;
			particle_emitter.particle=particle_mc;
			var emmx:XML = 
			<IDEEmitter particle="particle_mc" eps="10" burst="2" life="1" lifeSpread="*0.5" group="GroupParticle" groupAmount="0" groupProximity="10" angle="0" angleSpread="*360">
			  <Controllers>
			    <EmitterController/>
			    <ParticleController>
			      <ParticleTweenController duration="0" property="rotation">
			        <KeyframeContainer tweenClass="BasicTween" precision="0">
			          <Keyframe position="0" ease="linear" spread="*200" label="begin"/>
			          <Keyframe position="1" ease="linear" value="0" spread="*100" label="end"/>
			        </KeyframeContainer>
			      </ParticleTweenController>
			      <ParticlePhysicsController duration="0" flip="false" useAngle="true" property="x">
			        <ParticleTweenController duration="0" property="velocity">
			          <KeyframeContainer tweenClass="BasicTween" precision="1">
			            <Keyframe position="0" ease="linear" value="3" spread="*0" label="begin"/>
			            <Keyframe position="1" ease="linear" spread="*0" label="end"/>
			          </KeyframeContainer>
			        </ParticleTweenController>
			        <ParticleTweenController duration="0" property="acceleration">
			          <KeyframeContainer tweenClass="BasicTween" precision="2">
			            <Keyframe position="0" ease="linear" spread="*0" label="begin"/>
			            <Keyframe position="1" ease="linear" spread="*0" label="end"/>
			          </KeyframeContainer>
			        </ParticleTweenController>
			        <ParticleTweenController duration="0" property="friction">
			          <KeyframeContainer tweenClass="BasicTween" precision="2">
			            <Keyframe position="0" ease="linear" spread="*0" label="begin"/>
			            <Keyframe position="1" ease="linear" spread="*0" label="end"/>
			          </KeyframeContainer>
			        </ParticleTweenController>
			      </ParticlePhysicsController>
			      <ParticleTweenController duration="0" property="alpha">
			        <KeyframeContainer tweenClass="BasicTween" precision="2">
			          <Keyframe position="0" ease="linear" value="0.1" spread="*0.8" label="begin"/>
			          <Keyframe position="1" ease="linear" spread="*0" label="end"/>
			        </KeyframeContainer>
			      </ParticleTweenController>
			      <ParticleTweenController duration="0" property="scale">
			        <KeyframeContainer tweenClass="BasicTween" precision="2">
			          <Keyframe position="0" ease="linear" value="0.3" spread="*0.5" label="begin"/>
			          <Keyframe position="1" ease="linear" value="0" spread="*0" label="end"/>
			        </KeyframeContainer>
			      </ParticleTweenController>
			      <ParticlePhysicsController duration="0" flip="true" useAngle="true" property="y">
			        <ParticleTweenController duration="0" property="velocity">
			          <KeyframeContainer tweenClass="BasicTween" precision="1">
			            <Keyframe position="0" ease="linear" value="3" spread="*0" label="begin"/>
			            <Keyframe position="1" ease="linear" spread="*0" label="end"/>
			          </KeyframeContainer>
			        </ParticleTweenController>
			        <ParticleTweenController duration="0" property="acceleration">
			          <KeyframeContainer tweenClass="BasicTween" precision="2">
			            <Keyframe position="0" ease="linear" spread="*0" label="begin"/>
			            <Keyframe position="1" ease="linear" spread="*0" label="end"/>
			          </KeyframeContainer>
			        </ParticleTweenController>
			        <ParticleTweenController duration="0" property="friction">
			          <KeyframeContainer tweenClass="BasicTween" precision="2">
			            <Keyframe position="0" ease="linear" spread="*0" label="begin"/>
			            <Keyframe position="1" ease="linear" spread="*0" label="end"/>
			          </KeyframeContainer>
			        </ParticleTweenController>
			      </ParticlePhysicsController>
			    </ParticleController>
			  </Controllers>
			</IDEEmitter>;
			particle_emitter.fromXML(emmx);
			particle_emitter.start();
		}
		public function key_down(event:KeyboardEvent):void {
			switch (event.keyCode) {
				case 39 :
					rear_motor_added.SetMotorSpeed(10);
					front_motor_added.SetMotorSpeed(10);
					break;
				case 37 :
					rear_motor_added.SetMotorSpeed(-10);
					front_motor_added.SetMotorSpeed(-10);
					break;
			}
		}
		public function debug_draw():void {
			var m_sprite:Sprite;
			m_sprite = new Sprite();
			addChild(m_sprite);
			var dbgDraw:b2DebugDraw = new b2DebugDraw();
			var dbgSprite:Sprite = new Sprite();
			m_sprite.addChild(dbgSprite);
			dbgDraw.SetSprite(m_sprite);
			dbgDraw.SetDrawScale(30);
			dbgDraw.SetFillAlpha(0.5);
			dbgDraw.SetLineThickness(1);
			dbgDraw.SetFlags(b2DebugDraw.e_shapeBit);
			world.SetDebugDraw(dbgDraw);
		}
		public function update(e : Event):void {
			world.Step(1/30,10,10);
			world.ClearForces();
			world.DrawDebugData();
			for (var bb:b2Body = world.GetBodyList(); bb; bb = bb.GetNext()) {
				if (bb.GetUserData()) {
					particle_emitter.x=bb.GetPosition().x*30;
					particle_emitter.y=bb.GetPosition().y*30;
				}
			}
		}
	}
}

As you can see, the partigen code is very small, the most of the code is the particle XML itself.

And this is the result: I wanted fake bodies to spread from the car’s body.

Move the car with left/right arrow keys and enjoy.

Final considerations

Partigen 2 is the most complete tool to create particle effects with Flash IDE and API, in a couple of minutes you will be able to create amazing effects, saving hours of trial and error.

Desuade is so confident that you’ll fall even more in love with Partigen 2, it comes with a 100% satisfaction, 60 day money-back guarantee. A single license costs $97, and it’s positively a must-have.

Rate this post: 1 Star2 Stars3 Stars4 Stars5 Stars (2 votes, average: 5.00 out of 5)
Loading ... Loading ...
If you found this post useful, please consider a small donation.
» Flash Templates provided by Template Monster are pre-made web design products developed using Flash technology.
They can be easily customized to meet the unique requirements of your project.

2 Responses to “Create incredible particle effects with Partigen 2”

  1. Klaus Klapper on February 8th, 2010 2:13 pm

    Wow, that looks amazing. I’ll love to start playing with it!

  2. Flo - derhess.de on February 10th, 2010 10:12 am

    wow, that is a real cool approach! I like it!

    Maybe my old blog post about Flash Game Frameworks are interesting for you?!
    http://blog.derhess.de/2009/09/04/flash-game-frameworks-classes-and-libraries/

    At the moment I am looking for some review of these Flash Game Frameworks, do you know some good reviews about Push Button Engine, Flixel, Flash Punk etc.? Thx!

    Bye Flo

Leave a Reply




flash games company