當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。