当前位置: 首页>>代码示例>>C#>>正文


C# Particle.Initialize方法代码示例

本文整理汇总了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);
        }
开发者ID:JoeOsborn,项目名称:Cyclyc,代码行数:40,代码来源:ParticleSystem.cs

示例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;
        }
    }
开发者ID:mrjoelkemp,项目名称:giftxna,代码行数:41,代码来源:ParticleSystem.cs

示例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);
            }
开发者ID:josiah1888,项目名称:game-dev,代码行数:19,代码来源:ParticleSystem.cs

示例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);
 }
开发者ID:JuroGandalf,项目名称:Ragnarok,代码行数:9,代码来源:ParticleCreator.cs


注:本文中的Particle.Initialize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。