当前位置: 首页>>代码示例>>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;未经允许,请勿转载。