Esempio n. 1
1
        protected override void LoadContent()
        {
            _spriteBatch = new SpriteBatch(GraphicsDevice);
            _bitmapFont = Content.Load<BitmapFont>("Fonts/courier-new-32");
            _tiledMap = Content.Load<TiledMap>("Tilesets/level01");

            _world.CreateGrid(_tiledMap.GetLayer<TiledTileLayer>("Tile Layer 1"));

            var fireballTexture = Content.Load<Texture2D>("Sprites/fireball");
            var spriteSheetAtlas = TextureAtlas.Create(fireballTexture, 512, 197);

            _sprite = new Sprite(spriteSheetAtlas[0])
            {
                Position = new Vector2(850, 200),
                Scale = new Vector2(0.5f)
            };
            _spriteAnimator = new SpriteAnimator(_sprite, spriteSheetAtlas, 15);

            var zombieSheet = Content.Load<TextureAtlas>("Sprites/zombie-atlas");
            _zombie = new Zombie(zombieSheet)
            {
                Position = new Vector2(300, 500)
            };

            _world.CreateBody(_zombie);
        }
Esempio n. 2
0
        protected override void LoadContent()
        {
            _spriteBatch = new SpriteBatch(GraphicsDevice);
            Content.Load<BitmapFont>("Fonts/courier-new-32");
            _tiledMap = Content.Load<TiledMap>("Tilesets/level01");

            _world = new CollisionWorld(new Vector2(0, 900));
            _world.CreateGrid(_tiledMap.GetLayer<TiledTileLayer>("Tile Layer 1"));

            var animationGroup = Content.Load<SpriteSheetAnimationGroup>("Sprites/zombie-animations");
            _zombie = new Zombie(animationGroup);
            var zombieActor = _world.CreateActor(_zombie);
            zombieActor.Position = new Vector2(462.5f, 896f);
        }
 public void LoadMap(ContentManager contentManager, int id)
 {
     _tiledMap = contentManager.Load<TiledMap>(String.Format("maps/map{0}", id));
     _currentMapId = id;
     var tsx = (int)TileSize.X;
     var tsy = (int)TileSize.Y;
     _tileColliderBoxes = new List<Rectangle>();
     var blockedLayer = _tiledMap.GetLayer< TiledTileLayer>("Block");
     if (blockedLayer != null)
     {
         foreach (var tile in blockedLayer.Tiles)
         {
             if (tile.Id != 0)
                 _tileColliderBoxes.Add(new Rectangle(tile.X * tsx, tile.Y * tsy, tsx, tsy));
         }
     }
     
     _spikes = new List<Rectangle>();
     var spikesLayer = _tiledMap.GetLayer<TiledTileLayer>("Spikes");
     if (spikesLayer != null)
     {
         foreach (var tile in spikesLayer.Tiles)
         {
             if (tile.Id != 0)
                 _spikes.Add(new Rectangle(tile.X * tsx, tile.Y * tsy, tsx, tsy));
         }
     }
 }