本文整理汇总了C#中Particle.Initialize方法的典型用法代码示例。如果您正苦于以下问题:C# Particle.Initialize方法的具体用法?C# Particle.Initialize怎么用?C# Particle.Initialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Particle
的用法示例。
在下文中一共展示了Particle.Initialize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitializeParticle
/// <summary>
/// InitializeParticle randomizes some properties for a particle, then
/// calls initialize on it. It can be overriden by subclasses if they
/// want to modify the way particles are created. For example,
/// SmokePlumeParticleSystem overrides this function make all particles
/// accelerate to the right, simulating wind.
/// </summary>
/// <param name="p">the particle to initialize</param>
/// <param name="where">the position on the screen that the particle should be
/// </param>
protected virtual void InitializeParticle(Particle p, Vector2 where)
{
// first, call PickRandomDirection to figure out which way the particle
// will be moving. velocity and acceleration's values will come from this.
Vector2 direction = PickRandomDirection();
// pick some random values for our particle
float velocity =
Game1.RandomBetween(minInitialSpeed, maxInitialSpeed);
float acceleration =
Game1.RandomBetween(minAcceleration, maxAcceleration);
float lifetime =
Game1.RandomBetween(minLifetime, maxLifetime);
float scale =
Game1.RandomBetween(minScale, maxScale);
float rotationSpeed =
Game1.RandomBetween(minRotationSpeed, maxRotationSpeed);
float r = Game1.RandomBetween(minRed, maxRed);
float g = Game1.RandomBetween(minGreen, maxGreen);
float b = Game1.RandomBetween(minBlue, maxBlue);
float rot = PickRandomAngle();
// then initialize it with those random values. initialize will save those,
// and make sure it is marked as active.
p.Initialize(
where, rot, velocity * direction, acceleration * direction,
lifetime, scale, rotationSpeed, r, g, b);
}
示例2: InitializeParticle
/// <summary>
/// InitializeParticle randomizes some properties for a particle, then
/// calls initialize on it. It can be overriden by subclasses if they
/// want to modify the way particles are created. For example,
/// SmokePlumeParticleSystem overrides this function make all particles
/// accelerate to the right, simulating wind.
/// </summary>
/// <param name="p">the particle to initialize</param>
/// <param name="where">the position on the screen that the particle should be
/// </param>
protected virtual void InitializeParticle(Particle p, Vector2 where)
{
// first, call PickRandomDirection to figure out which way the particle
// will be moving. velocity and acceleration's values will come from this.
Vector2 direction = PickRandomDirection();
// pick some random values for our particle
float velocity =
Particle.RandomBetween(minInitialSpeed, maxInitialSpeed);
float acceleration =
Particle.RandomBetween(minAcceleration, maxAcceleration);
float lifetime =
Particle.RandomBetween(minLifetime, maxLifetime);
float scale =
Particle.RandomBetween(minScale, maxScale);
float rotationSpeed =
Particle.RandomBetween(minRotationSpeed, maxRotationSpeed);
// then initialize it with those random values. initialize will save those,
// and make sure it is marked as active.
p.Initialize(
where, velocity * direction, acceleration * direction,
lifetime, scale, rotationSpeed);
if (isCollidable)
{
p.Sphere.Radius = (texture.Width / 2) * scale;
p.Sphere.Center.X = where.X;
p.Sphere.Center.Y = where.Y;
}
}
示例3: InitializeParticle
protected virtual void InitializeParticle(Particle p, Vector2 where)
{
Vector2 direction = PickRandomDirection();
float velocity =
RandomBetween(minInitialSpeed, maxInitialSpeed);
float acceleration =
RandomBetween(minAcceleration, maxAcceleration);
float lifetime =
RandomBetween(minLifetime, maxLifetime);
float scale =
RandomBetween(minScale, maxScale);
float rotationSpeed =
RandomBetween(minRotationSpeed, maxRotationSpeed);
p.Initialize(
where, velocity * direction, acceleration * direction,
lifetime, scale, rotationSpeed);
}
示例4: DisposeParticle
/// <summary>
/// Returns a particle to the particle pool for reuse
/// </summary>
/// <param name="particle">The particle to return for reuse.</param>
public void DisposeParticle(Particle particle)
{
particle.Initialize();
m_particles.Push(particle);
}