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


C# Sprite.Create方法代码示例

本文整理汇总了C#中Microsoft.Xna.Framework.Graphics.Sprite.Create方法的典型用法代码示例。如果您正苦于以下问题:C# Sprite.Create方法的具体用法?C# Sprite.Create怎么用?C# Sprite.Create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Xna.Framework.Graphics.Sprite的用法示例。


在下文中一共展示了Sprite.Create方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UfoFiresBullet

 private void UfoFiresBullet()
 {
     Sprite newBullet = new Sprite(_ufobullet.Texture);
     Vector2 velocity = _ship.Position - _ufo.Position;
     velocity.Normalize();
     newBullet.Rotation = (float) Math.Atan2(velocity.Y, velocity.X) + MathHelper.PiOver2;
     velocity *= 6.0f;
     newBullet.Velocity = velocity;
     newBullet.Position = _ufo.Position;
     newBullet.Damage = 1;
     newBullet.Create();
     _ufobullets.Add(newBullet);
 }
开发者ID:KarolDabrowski,项目名称:Asteroids-XNA,代码行数:13,代码来源:GamePage.xaml.cs

示例2: ShipSpecialAttack

        private void ShipSpecialAttack()
        {
            //_ship.Velocity += new Vector2(
            //    (float) (Math.Cos(_ship.Rotation - MathHelper.PiOver2)*0.5f),
            //    (float) ((Math.Sin(_ship.Rotation - MathHelper.PiOver2)*0.5f)));
            float chunk = MathHelper.TwoPi/BulletsInSpecialAttack;

            for (int i = 0; i < BulletsInSpecialAttack; i++)
            {
                Sprite newBullet = new Sprite(_specialBulletTexture);
                newBullet.Position = _ship.Position;
                newBullet.Damage = 2;
                newBullet.Velocity = new Vector2((float)Math.Cos(-MathHelper.Pi + chunk * i), (float)Math.Sin(-MathHelper.Pi + chunk * i))*10;
                newBullet.Create();
                _bullets.Add(newBullet);
            }
        }
开发者ID:KarolDabrowski,项目名称:Asteroids-XNA,代码行数:17,代码来源:GamePage.xaml.cs

示例3: NewAsteroid

        private void NewAsteroid(Sprite a, int index)
        {
            Sprite tempSprite = new Sprite(_asteroidTextures[index])
                                    {
                                        Index = index,
                                        Position = a.Position,
                                        Velocity = RandomVelocity(),
                                        Rotation = (float) _random.NextDouble()*
                                                   MathHelper.Pi*4 - MathHelper.Pi*2

                                    };

            if (a.Index < 3)
            {
                tempSprite.Life = 3;
            }
            else if (a.Index < 6)
            {
                tempSprite.Life = 1;
            }

            tempSprite.Create();
            _asteroids.Add(tempSprite);
        }
开发者ID:KarolDabrowski,项目名称:Asteroids-XNA,代码行数:24,代码来源:GamePage.xaml.cs

示例4: ShipFiresBullet

 private void ShipFiresBullet()
 {
     Sprite newBullet = new Sprite(_bullet.Texture);
     Vector2 velocity = new Vector2(
         (float)Math.Cos(_ship.Rotation - MathHelper.PiOver2) ,
         (float)Math.Sin(_ship.Rotation - MathHelper.PiOver2) );
     velocity.Normalize();
     velocity *= 10.0f;
     newBullet.Velocity = velocity;
     newBullet.Position = _ship.Position + newBullet.Velocity*2;
     newBullet.Damage = 1;
     newBullet.Rotation = _ship.Rotation;
     newBullet.Create();
     _bullets.Add(newBullet);
 }
开发者ID:KarolDabrowski,项目名称:Asteroids-XNA,代码行数:15,代码来源:GamePage.xaml.cs

示例5: GenerateAidkits

        /*
         *
         * UPDATE LOGIC BLOC
         *
         *
         */
        private void GenerateAidkits(TimeSpan totalTime)
        {
            if (_random.Next(0, 700) == 301)
            {
                Sprite aidkit = new Sprite(_aidkitTexture);

                double xPos = 0;
                double yPos = 0;

                int value = _random.Next(0, 4);

                switch (value)
                {
                    case 0:
                    case 1:
                        xPos = aidkit.Width + _random.NextDouble() * 40;
                        yPos = _random.NextDouble() * _screenHeight;
                        break;
                    case 2:
                    case 3:
                        xPos = _screenWidth - _random.NextDouble() * 40;
                        yPos = _random.NextDouble() * _screenHeight;
                        break;
                    case 4:
                    case 5:
                        xPos = _random.NextDouble() * _screenWidth;
                        yPos = aidkit.Height + _random.NextDouble() * 40;
                        break;
                    default:
                        xPos = _random.NextDouble() * _screenWidth;
                        yPos = _screenHeight - _random.NextDouble() * 40;
                        break;
                }

                aidkit.Position = new Vector2((float)xPos, (float)yPos);
                aidkit.Rotation = (float)_random.NextDouble() *
                                         MathHelper.Pi * 4 - MathHelper.Pi * 2;
                aidkit.Life = _random.Next(3, 6);
                aidkit.LastUpdate = totalTime.TotalMilliseconds;
                aidkit.Create();
                _aidkits.Add(aidkit);
            }
        }
开发者ID:KarolDabrowski,项目名称:Asteroids-XNA,代码行数:49,代码来源:GamePage.xaml.cs


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