コード例 #1
0
        public TileMap(Tileset tileset, MapLayer layer)
        {
            tilesets = new List<Tileset>();
            tilesets.Add(tileset);

            mapLayers = new List<MapLayer>();
            mapLayers.Add(layer);

            mapWidth = mapLayers[0].Width;
            mapHeight = mapLayers[0].Height;
        }
コード例 #2
0
        protected override void LoadContent()
        {
            Texture2D spriteSheet = Game.Content.Load<Texture2D>(@"Textures\Characters\Overworld\" + GameRef.CharacterSelectScreen.SelectedCharacter.Replace(" ", String.Empty).ToLower() + "_20x20_8");
            Dictionary<AnimationKey, Animation> animations = new Dictionary<AnimationKey, Animation>();

            Animation animation = new Animation(2, 20, 20, 0, 0);
            animations.Add(AnimationKey.Down, animation);

            animation = new Animation(2, 20, 20, 0, 20);
            animations.Add(AnimationKey.Left, animation);

            animation = new Animation(2, 20, 20, 0, 40);
            animations.Add(AnimationKey.Right, animation);

            animation = new Animation(2, 20, 20, 0, 60);
            animations.Add(AnimationKey.Up, animation);

            sprite = new AnimatedSprite(spriteSheet, animations);

            Texture2D tilesetTexture = Game.Content.Load<Texture2D>(@"Textures\Tilesets\ponyville_tileset");
            tileset = new Tileset(tilesetTexture, 11, 9, 16, 16);

            tilesetTexture = Game.Content.Load<Texture2D>(@"Textures\Tilesets\example_tileset1");
            Tileset tileset1 = new Tileset(tilesetTexture, 8, 8, 16, 16);

            tilesetTexture = Game.Content.Load<Texture2D>(@"Textures\Tilesets\example_tileset2");
            Tileset tileset2 = new Tileset(tilesetTexture, 8, 8, 16, 16);

            List<Tileset> tilesets = new List<Tileset>();
            tilesets.Add(tileset);
            tilesets.Add(tileset1);
            tilesets.Add(tileset2);

            MapLayer layer = TileMapLoader.LoadTmx(@"Content\Maps\ponyville.xml");

            List<MapLayer> mapLayers = new List<MapLayer>();
            mapLayers.Add(layer);

            map = new TileMap(tilesets, mapLayers);

            base.LoadContent();
        }