Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
0
        protected override void LoadContent()
        {
            _spriteBatch = new SpriteBatch(GraphicsDevice);
            Content.Load <BitmapFont>("Fonts/courier-new-32");
            _map = Content.Load <TiledMap>("Tilesets/level01");

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

            var zombieAnimations = Content.Load <SpriteSheetAnimationFactory>("Sprites/zombie-animations");

            _zombie = new Zombie(zombieAnimations);
            var zombieActor = _world.CreateActor(_zombie);

            zombieActor.Position = new Vector2(462.5f, 896f);

            var fireballTexture = Content.Load <Texture2D>("Sprites/fireball");
            var fireballAtlas   = TextureAtlas.Create("Sprites/fireball-atlas", fireballTexture, 130, 50);

            _animation = new SpriteSheetAnimation("fireballAnimation", fireballAtlas.Regions.ToArray())
            {
                FrameDuration = 0.2f
            };
            _fireballSprite = new Sprite(_animation.CurrentFrame)
            {
                Position = _zombie.Position
            };

            var motwTexture          = Content.Load <Texture2D>("Sprites/motw");
            var motwAtlas            = TextureAtlas.Create("Sprites/fireball-atlas", motwTexture, 52, 72);
            var motwAnimationFactory = new SpriteSheetAnimationFactory(motwAtlas);

            motwAnimationFactory.Add("idle", new SpriteSheetAnimationData(new[] { 0 }));
            motwAnimationFactory.Add("walkSouth", new SpriteSheetAnimationData(new[] { 0, 1, 2, 1 }, isLooping: false));
            motwAnimationFactory.Add("walkWest", new SpriteSheetAnimationData(new[] { 12, 13, 14, 13 }, isLooping: false));
            motwAnimationFactory.Add("walkEast", new SpriteSheetAnimationData(new[] { 24, 25, 26, 25 }, isLooping: false));
            motwAnimationFactory.Add("walkNorth", new SpriteSheetAnimationData(new[] { 36, 37, 38, 37 }, isLooping: false));
            _motwSprite          = new AnimatedSprite(motwAnimationFactory);
            _motwSprite.Position = new Vector2(350, 800);
            _motwSprite.Play("walkSouth").IsLooping = true;
        }