Пример #1
0
        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;
        }
Пример #2
0
 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";
     }
 }
Пример #3
0
        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;
            }
        }
Пример #4
0
 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;
 }