當前位置: 首頁>>代碼示例>>C#>>正文


C# Sprite.AddAnimation方法代碼示例

本文整理匯總了C#中Microsoft.Xna.Framework.Graphics.Sprite.AddAnimation方法的典型用法代碼示例。如果您正苦於以下問題:C# Sprite.AddAnimation方法的具體用法?C# Sprite.AddAnimation怎麽用?C# Sprite.AddAnimation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Microsoft.Xna.Framework.Graphics.Sprite的用法示例。


在下文中一共展示了Sprite.AddAnimation方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: LoadSprite

        static Sprite LoadSprite(Game game, string type, int id)
        {
            string spritePath = string.Format(SpritePathFormat, type, id.ToString("D2"));
            var sprite = new Sprite(game.Content.Load<Texture2D>(spritePath), new Point(16, 16));
            sprite.AddAnimation("stand", new[] { 6, 7, 8 }, TimeSpan.FromMilliseconds(300), true);
            sprite.AddAnimation("run", new[] { 0, 1, 2, 1 }, TimeSpan.FromMilliseconds(100), true);
            sprite.AddAnimation("hug", new[] { 9, 10, 11 }, TimeSpan.FromMilliseconds(200), false);
            sprite.CurrentAnimation = "stand";

            return sprite;
        }
開發者ID:jvlppm,項目名稱:ggj14-zombie-mg,代碼行數:11,代碼來源:NPC.cs

示例2: PhysicsEntity

 public PhysicsEntity(Game game, string texturePath)
     : this()
 {
     if (texturePath != null)
     {
         Sprite = new Sprite(game.Content.Load<Texture2D>(texturePath), 1, 1);
         Sprite.AddAnimation( "default", 0, 1, TimeSpan.FromSeconds(1));
         Sprite.Origin = new Vector2(Sprite.FrameSize.X, Sprite.FrameSize.Y) / 2;
         Sprite.CurrentAnimation = "default";
     }
 }
開發者ID:jvlppm,項目名稱:ggj14-zombie-mg,代碼行數:11,代碼來源:PhysicsEntity.cs

示例3: CreateZombies

        void CreateZombies()
        {
            var cZombie = new[] { "npc-zombie-01", "npc-zombie-02", "npc-zombie-03", "npc-zombie-04", "player-zombie" };
            var cNormal = new[] { "npc-normal-01", "npc-normal-02", "npc-normal-03", "npc-normal-04", "player-normal" };

            var classes = new[] { cZombie, cNormal };

            var zombieX = Viewport.Width / 4 - 80 * _gui.Scale.X;

            foreach (var c in classes)
            {
                float zombieY = (int)textBasePosY;
                float spaceY = (textPosY - textBasePosY) / cZombie.Length - 64 * _gui.Scale.Y;

                foreach (var sprite in c)
                {
                    var texture = Game.Content.Load<Texture2D>("Images/Sprites/" + sprite);
                    var s = new Sprite(texture, new Point(16, 16));
                    s.AddAnimation("dance", new int[] { 0, 1, 2, 3, 4, 5 }, TimeSpan.FromMilliseconds(200));
                    var comp = new SpriteComponent(s)
                    {
                        Position = new Point((int)zombieX, (int)zombieY),
                        Scale = new Vector2(4)
                    };
                    _gui.Add(comp);
                    zombieY += 64 * _gui.Scale.Y + spaceY;
                }
                zombieX += 80;
            }
        }
開發者ID:jvlppm,項目名稱:ggj14-zombie-mg,代碼行數:30,代碼來源:CreditsScreen.cs

示例4: LoadSprite

 static Sprite LoadSprite(Game game, string path)
 {
     var texture = game.Content.Load<Texture2D>(path);
     var sprite = new Sprite(texture, 1, 1)
     {
         Origin = new Vector2(texture.Width / 2, texture.Height / 2)
     };
     sprite.AddAnimation("default", new[] { 0 }, TimeSpan.FromSeconds(1), true);
     return sprite;
 }
開發者ID:jvlppm,項目名稱:ggj14-zombie-mg,代碼行數:10,代碼來源:ParticleEmiter.cs


注:本文中的Microsoft.Xna.Framework.Graphics.Sprite.AddAnimation方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。