Game Development Reference
In-Depth Information
How it works...
Particle emitters are normally limited in what control you have over the particles. The
ParticleInfluencer
class gives us some basic control during particle creation.
Since the birds are flat planes, they look best when viewed straight on. This creates a prob-
lem when we have said that they should always point in the direction they're flying if
they're moving along the
y
axis.
The
influenceParticle
method is a method implemented from the
ParticleIn-
fluencer
interface and it is called upon the creation of every new particle. Since the
DefaultParticleInfluencer
instance is already applying a velocity with variation,
we just needed to remove any Y-velocity.
In the
ParticleEmitter
class, we commented out a line in the
update
method.
That's the current animation logic that will override our changes every time. A workaround
would be to let the
ParticleInfluencer
class keep track of the current frame, but
that would make all the birds have the same frame. Another alternative would be to move it
to one of the other
ParticleInfluencer
classes.
By using the control pattern to update the
ParticleInfluencer
class, we can offset
some code and keep minimum changes in the
ParticleEmitter
class.
Unfortunately, the changes we made to the
ParticleEmitter
class won't be picked up
by Scene Composer, as it uses its own compiled classes. So to see it, we had to start an ap-
plication and load the scene there.