protected override void LoadContent() { _spriteBatch = new SpriteBatch(GraphicsDevice); var zombieAnimations = Content.Load <SpriteSheetAnimationFactory>("Animations/zombie-animations"); _zombie = new Zombie(zombieAnimations) { Position = new Vector2(100, 100) }; var fireballTexture = Content.Load <Texture2D>("Animations/fireball"); var fireballAtlas = TextureAtlas.Create("Animations/fireball-atlas", fireballTexture, 130, 50); _animation = new SpriteSheetAnimation("fireballAnimation", fireballAtlas.Regions.ToArray()) { FrameDuration = 0.2f }; _fireballSprite = new Sprite(_animation.CurrentFrame);// { Position = new Vector2(-150, 100) }; var motwTexture = Content.Load <Texture2D>("Animations/motw"); var motwAtlas = TextureAtlas.Create("Animations/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);// { Position = new Vector2(20, 20) }; _motwSprite.Play("walkSouth").IsLooping = true; }
private AnimatedSprite MakeFireball() { // in this example, we're making an animated fireball manually in code. // after the texture is loaded, we can split it up into it's different sprites using texture atlas. // then we make a sprite sheet do define the frames of the animation. var texture = Content.Load <Texture2D>("Animations/fireball"); var textureAtlas = TextureAtlas.Create("Animations/fireball-atlas", texture, 130, 50); var spriteSheet = new SpriteSheet { TextureAtlas = textureAtlas, Cycles = { { "flaming", new SpriteSheetAnimationCycle { IsLooping = true, IsPingPong = true, FrameDuration = 0.2f, Frames = { // TODO: Fix per frame duration new SpriteSheetAnimationFrame(0, duration: 0.1f), new SpriteSheetAnimationFrame(1, duration: 0.15f), new SpriteSheetAnimationFrame(2, duration: 0.3f) } } } } }; return(new AnimatedSprite(spriteSheet, "flaming")); }
public Animation(Texture2D texture, SpriteSheetData spriteSheetData, int direction = 0, bool isPlayer = false) { var spriteWidth = spriteSheetData.Width; var spriteHeight = spriteSheetData.Height; var objectTexture = texture; var objectAtlas = TextureAtlas.Create("objectAtlas", objectTexture, spriteWidth, spriteHeight); var animationFactory = new SpriteSheetAnimationFactory(objectAtlas); for (int i = 0; i < spriteSheetData.AnimationName.Count; i++) { animationFactory.Add(spriteSheetData.AnimationName[i], new SpriteSheetAnimationData(spriteSheetData.FrameArray[i], spriteSheetData.FrameDuration[i], spriteSheetData.IsLooping[i])); } if (isPlayer) { objectAnimated = new AnimatedSprite(animationFactory, HUD.PlayerCurrentState.ToString()); } else { objectAnimated = new AnimatedSprite(animationFactory, "Idle"); } objectSprite = objectAnimated; objectSprite.Origin = Vector2.Zero; if (direction == (int)Direction.Right) { objectAnimated.Effect = SpriteEffects.None; } else { objectAnimated.Effect = SpriteEffects.FlipHorizontally; } }
public override void Load(ContentManager content) { #region INITIALIZE TEXTURE ATLAS AND ANIMATION var spriteWidth = 16; var spriteHeight = 16; var objectTexture = content.Load <Texture2D>("Sprites/Player/s_player_overworld_atlas"); var objectAtlas = TextureAtlas.Create("objectAtlas", objectTexture, spriteWidth, spriteHeight); var animationFactory = new SpriteSheetAnimationFactory(objectAtlas); animationFactory.Add("idle", new SpriteSheetAnimationData(new[] { 0 })); animationFactory.Add("walk", new SpriteSheetAnimationData(new[] { 0, 1 }, frameDuration: 0.2f, isLooping: true)); #endregion objectAnimated = new AnimatedSprite(animationFactory, "idle"); objectSprite = objectAnimated; base.Load(content); objectSprite.Origin = Vector2.Zero + origin; //set custom hitbox boundingBoxTopLeft = Vector2.Zero; boundingBoxBottomRight = new Vector2(16, 16); }
public void TextureAtlas_Create_WithMaxRegionCount_Test() { var texture = new Texture2D(TestHelper.CreateGraphicsDevice(), 64, 64); var atlas = TextureAtlas.Create(null, texture, 32, 32, maxRegionCount: 3); Assert.AreEqual(3, atlas.RegionCount); }
public override void Load(ContentManager content) { // initiliaze sprite spriteWidth = 20; spriteHeight = 20; objectTexture = content.Load <Texture2D>("Sprites/playerOverworld"); objectAtlas = TextureAtlas.Create("objectAtlas", objectTexture, spriteWidth, spriteHeight); //create animations from sprite sheet animationFactory = new SpriteSheetAnimationFactory(objectAtlas); animationFactory.Add("down", new SpriteSheetAnimationData(new[] { 0 })); animationFactory.Add("downwalk", new SpriteSheetAnimationData(new[] { 1, 2 }, frameDuration: 0.2f, isLooping: true)); animationFactory.Add("up", new SpriteSheetAnimationData(new[] { 3 })); animationFactory.Add("upwalk", new SpriteSheetAnimationData(new[] { 4, 5 }, frameDuration: 0.2f, isLooping: true)); animationFactory.Add("right", new SpriteSheetAnimationData(new[] { 6 })); animationFactory.Add("rightwalk", new SpriteSheetAnimationData(new[] { 7, 8 }, frameDuration: 0.2f, isLooping: true)); animationFactory.Add("left", new SpriteSheetAnimationData(new[] { 9 })); animationFactory.Add("leftwalk", new SpriteSheetAnimationData(new[] { 10, 11 }, frameDuration: 0.2f, isLooping: true)); objectAnimated = new AnimatedSprite(animationFactory, "down"); objectSprite = objectAnimated; objectSprite.Depth = 0.1f; base.Load(content); boundingBoxWidth = 16; boundingBoxHeight = 16; boundingBoxOffset = new Vector2(2, 4); }
public Entity CreatePlayer(Vector2 position) { var dudeTexture = _contentManager.Load <Texture2D>("hero"); var dudeAtlas = TextureAtlas.Create("dudeAtlas", dudeTexture, 16, 16); var entity = _world.CreateEntity(); var spriteSheet = new SpriteSheet { TextureAtlas = dudeAtlas }; AddAnimationCycle(spriteSheet, "idle", new[] { 0, 1, 2, 1 }); AddAnimationCycle(spriteSheet, "walk", new[] { 6, 7, 8, 9, 10, 11 }); AddAnimationCycle(spriteSheet, "jump", new[] { 10, 12 }, false); AddAnimationCycle(spriteSheet, "fall", new[] { 13, 14 }, false); AddAnimationCycle(spriteSheet, "swim", new[] { 18, 19, 20, 21, 22, 23 }); AddAnimationCycle(spriteSheet, "kick", new[] { 15 }, false, 0.3f); AddAnimationCycle(spriteSheet, "punch", new[] { 26 }, false, 0.3f); AddAnimationCycle(spriteSheet, "cool", new[] { 17 }, false, 0.3f); entity.Attach(new AnimatedSprite(spriteSheet, "idle")); entity.Attach(new Transform2(position, 0, Vector2.One * 4)); entity.Attach(new Body { Position = position, Size = new Vector2(32, 64), BodyType = BodyType.Dynamic }); entity.Attach(new Player()); return(entity); }
public override void Load(ContentManager content) { // initiliaze sprite spriteWidth = 48; spriteHeight = 32; objectTexture = content.Load <Texture2D>("Sprites/player"); objectAtlas = TextureAtlas.Create("objectAtlas", objectTexture, spriteWidth, spriteHeight); //create animations from sprite sheet animationFactory = new SpriteSheetAnimationFactory(objectAtlas); animationFactory.Add("idle", new SpriteSheetAnimationData(new[] { 0 })); animationFactory.Add("walk", new SpriteSheetAnimationData(new[] { 1, 2, 3, 4 }, frameDuration: 0.1f, isLooping: true)); animationFactory.Add("jump", new SpriteSheetAnimationData(new[] { 3 })); animationFactory.Add("attack", new SpriteSheetAnimationData(new[] { 6, 7, 8, 9 }, frameDuration: 0.1f, isLooping: true)); animationFactory.Add("attackDown", new SpriteSheetAnimationData(new[] { 6, 7, 8, 9 }, frameDuration: 0.1f, isLooping: true)); animationFactory.Add("hurt", new SpriteSheetAnimationData(new[] { 3 })); animationFactory.Add("duck", new SpriteSheetAnimationData(new[] { 10 }, frameDuration: 0.1f, isLooping: true)); objectAnimated = new AnimatedSprite(animationFactory, "idle"); objectSprite = objectAnimated; objectSprite.Depth = 0.1f; // load sound effects jumpSFX = content.Load <SoundEffect>("Audio/Sound Effects/Jump"); attackSFX = content.Load <SoundEffect>("Audio/Sound Effects/playerAttack"); hurtSFX = content.Load <SoundEffect>("Audio/Sound Effects/playerHurt"); deadSFX = content.Load <SoundEffect>("Audio/Sound Effects/playerDeath"); base.Load(content); boundingBoxWidth = 14; boundingBoxHeight = 24; boundingBoxOffset = new Vector2(17, 7); }
public Entity CreatePlayer(Vector2 position) { var dudeTexture = _contentManager.Load <Texture2D>("Graphics/hero"); var dudeAtlas = TextureAtlas.Create("dudeAtlas", dudeTexture, 16, 16); var entity = _world.CreateEntity(); var animationFactory = new SpriteSheetAnimationFactory(dudeAtlas); animationFactory.Add("idle", new SpriteSheetAnimationData(new[] { 0, 1, 2, 1 })); animationFactory.Add("walk", new SpriteSheetAnimationData(new[] { 6, 7, 8, 9, 10, 11 }, frameDuration: 0.1f)); animationFactory.Add("combat", new SpriteSheetAnimationData(new[] { 25 }, frameDuration: 0.1f, isLooping: false)); animationFactory.Add("guard", new SpriteSheetAnimationData(new[] { 24 }, frameDuration: 0.3f, isLooping: false)); entity.Attach(new AnimatedSprite(animationFactory, "idle")); entity.Attach(new Transform2(position, 0, Vector2.One * 4)); entity.Attach(new Body { Position = position, Size = new Vector2(40, 96), BodyType = BodyType.Dynamic }); entity.Attach(new Focusable { IsFocused = true }); entity.Attach(new Health() { LifePoints = 3 }); entity.Attach(new Player()); return(entity); }
public Entity CreateNecromancer(Vector2 position) { var necroTexture = _contentManager.Load <Texture2D>("Graphics/YeOldyNecroGuy"); var necroAtlas = TextureAtlas.Create("necroAtlas", necroTexture, 28, 28); var entity = _world.CreateEntity(); var animationFactory = new SpriteSheetAnimationFactory(necroAtlas); animationFactory.Add("idle", new SpriteSheetAnimationData(new[] { 0, 1, 2, 1 })); animationFactory.Add("walk", new SpriteSheetAnimationData(new[] { 6, 7, 8, 9, 10, 11 }, frameDuration: 0.1f)); animationFactory.Add("combat", new SpriteSheetAnimationData(new[] { 25 }, frameDuration: 0.1f, isLooping: false)); entity.Attach(new AnimatedSprite(animationFactory, "idle")); entity.Attach(new Transform2(position, 0, Vector2.One * 4)); entity.Attach(new Body { Position = position, Size = new Vector2(40, 96), BodyType = BodyType.Static }); entity.Attach(new Health() { LifePoints = 3 }); entity.Attach(new Enemy() { Facing = Facing.Left }); return(entity); }
public EntityFactory(EntityComponentSystem entityComponentSystem) { _entityComponentSystem = entityComponentSystem; var texture = Game1.Instance.Content.Load <Texture2D>("free-tileset"); _tilesetAtlas = TextureAtlas.Create("tiny-characters-atlas", texture, 128, 128, 100, 2, 2); }
public Tileset(Texture2D texture, int tileWidth, int tileHeight) { TileWidth = tileWidth; TileHeight = tileHeight; _atlas = TextureAtlas.Create("", texture, tileWidth, tileHeight); _columns = texture.Width / tileWidth; }
public static void LoadTextures(ContentManager content) { playerAtlas = TextureAtlas.Create("Player", content.Load <Texture2D>("Textures/PlayerSheet"), tileSize, tileSize); tileAtlas = TextureAtlas.Create("Tiles", content.Load <Texture2D>("Textures/TileSheet"), tileSize, tileSize); ProcessPlayer(); ProcessTiles(); }
public void TextureAtlas_Create_WithMarginAndSpacing_Test() { var texture = new Texture2D(TestHelper.CreateGraphicsDevice(), 28, 28); var atlas = TextureAtlas.Create(null, texture, 10, 10, margin: 3, spacing: 2); Assert.AreEqual(4, atlas.RegionCount); Assert.IsTrue(atlas.Regions.All(i => i.Width == 10 && i.Height == 10)); Assert.AreEqual(atlas[0].X, 3); Assert.AreEqual(atlas[0].Y, 3); Assert.AreEqual(atlas[3].X, 15); Assert.AreEqual(atlas[3].Y, 15); }
public void TextureAtlas_Create_WithSpacing_Test() { var texture = new Texture2D(TestHelper.CreateGraphicsDevice(), 24, 24); var atlas = TextureAtlas.Create(texture, 10, 10, spacing: 2); Assert.AreEqual(4, atlas.RegionCount); Assert.IsTrue(atlas.Regions.All(i => i.Width == 10 && i.Height == 10)); Assert.AreEqual(atlas[0].X, 0); Assert.AreEqual(atlas[0].Y, 0); Assert.AreEqual(atlas[3].X, 12); Assert.AreEqual(atlas[3].Y, 12); }
/// <summary> /// Initializes a new instance of the <see cref="T:MB2D.Tiles.TileMap"/> class. /// Seperates the texture into a series of regions. /// </summary> /// <param name="texture">Texture to use in the texture atlas.</param> /// <param name="cellSize">The size of each cell in the texture atlas.</param> /// <param name="margin">Margin to apply to each rendered tile.</param> /// <param name="spacing">Spacing to apply to each rendered tile.</param> /// <param name="offset">Offset to apply to the x and y coordinates of each tile when rendering.</param> /// <param name="scale">Scale vector to apply to each cell when rendering.</param> public TileMap( Texture2D texture, int cellSize, int margin = 0, int spacing = 0, int offset = 0, float scale = 1.0f ) { _width = texture.Width; _height = texture.Height; _cellSize = cellSize; _offset = offset; _scale = new Vector2(scale, scale); _worldCellSize = (_cellSize * _scale).ToPoint(); _atlas = TextureAtlas.Create("TileSet", texture, cellSize, cellSize, margin: margin, spacing: spacing); }
public void TextureAtlas_Create_WithDefaultParameters_Test() { var texture = new Texture2D(TestHelper.CreateGraphicsDevice(), 50, 100) { Name = "testTexture" }; var atlas = TextureAtlas.Create(null, texture, 25, 50); Assert.AreEqual(4, atlas.RegionCount); Assert.IsTrue(atlas.Regions.All(i => i.Width == 25)); Assert.IsTrue(atlas.Regions.All(i => i.Height == 50)); Assert.IsTrue(atlas.Regions.All(i => ReferenceEquals(i.Texture, texture))); Assert.IsTrue(atlas.Regions.All(i => i.Name.StartsWith(texture.Name))); }
public Shuriken(Entities entities, GameObject owner, ContentManager content) { _entities = entities; _owner = owner; _texture = content.Load <Texture2D>("Textures/s_star"); // create animation sprite var spriteWidth = 9; var spriteHeight = 9; var objectAtlas = TextureAtlas.Create("objectAtlas", _texture, spriteWidth, spriteHeight); _animationFactory = new SpriteSheetAnimationFactory(objectAtlas); _animationFactory.Add("Init", new SpriteSheetAnimationData(new[] { 0, 1 }, 0.05f, true)); }
public FlameStrike(Entities entities, GameObject owner, ContentManager content) { _entities = entities; _owner = owner; _texture = content.Load <Texture2D>("Textures/s_flame_strike"); // create animation sprite var spriteWidth = 32; var spriteHeight = 32; var objectAtlas = TextureAtlas.Create("objectAtlas", _texture, spriteWidth, spriteHeight); _animationFactory = new SpriteSheetAnimationFactory(objectAtlas); _animationFactory.Add("Init", new SpriteSheetAnimationData(new[] { 0, 1, 2, 3, 4 }, 0.2f, true, false, true)); }
public void LoadContent() { var aliens = _game.Content.Load <Texture2D>("aliens"); var alienAtlas = TextureAtlas.Create("aliens", aliens, 16, 10); _animationFactory = new SpriteSheetAnimationFactory(alienAtlas); _animationFactory.Add("alien0", new SpriteSheetAnimationData(new[] { 0, 1 }, 0.5f)); _animationFactory.Add("alien1", new SpriteSheetAnimationData(new[] { 2, 3 }, 0.5f)); _animationFactory.Add("alien2", new SpriteSheetAnimationData(new[] { 4, 5 }, 0.5f)); _ship = _game.Content.Load <Texture2D>("ship"); _bullet = _game.Content.Load <Texture2D>("bullet"); }
public override void Load(ContentManager content) { objectTexture = content.Load <Texture2D>("Maps/MapObjects/" + platformSize); spriteWidth = objectTexture.Width; spriteHeight = objectTexture.Height; objectAtlas = TextureAtlas.Create("objectAtlas", objectTexture, spriteWidth, spriteHeight); animationFactory = new SpriteSheetAnimationFactory(objectAtlas); animationFactory.Add("idle", new SpriteSheetAnimationData(new[] { 0 })); objectAnimated = new AnimatedSprite(animationFactory, "idle"); objectSprite = objectAnimated; objectSprite.Depth = 0.5f; base.Load(content); boundingBoxWidth = objectTexture.Width; boundingBoxHeight = objectTexture.Height; }
public Entity CreateBlue(Vector2 position) { var dudeTexture = _contentManager.Load <Texture2D>("blueguy"); var dudeAtlas = TextureAtlas.Create("blueguyAtlas", dudeTexture, 16, 16); var entity = _world.CreateEntity(); //var animationFactory = new SpriteSheetAnimationFactory(dudeAtlas); //animationFactory.Add("idle", new SpriteSheetAnimationData(new[] { 0, 1, 2, 3, 2, 1 })); //animationFactory.Add("walk", new SpriteSheetAnimationData(new[] { 6, 7, 8, 9, 10, 11 }, frameDuration: 0.1f)); //animationFactory.Add("jump", new SpriteSheetAnimationData(new[] { 10, 12 }, frameDuration: 1.0f, isLooping: false)); //entity.Attach(new AnimatedSprite(animationFactory, "idle") { Effect = SpriteEffects.FlipHorizontally }); entity.Attach(new Transform2(position, 0, Vector2.One * 4)); entity.Attach(new Body { Position = position, Size = new Vector2(32, 64), BodyType = BodyType.Dynamic }); entity.Attach(new Enemy()); return(entity); }
public Entity CreateReadySign(Vector2 position) { var ReadyTexture = _contentManager.Load <Texture2D>("Ready"); var readyAtlas = TextureAtlas.Create("dudeAtlas", ReadyTexture, 16, 16); var spriteSheet = new SpriteSheet { TextureAtlas = readyAtlas }; AddAnimationCycle(spriteSheet, "Ready", new[] { 0 }); AddAnimationCycle(spriteSheet, "NotReady", new[] { 1 }); var entity = _world.CreateEntity(); entity.Attach(new AnimatedSprite(spriteSheet, "NotReady")); var transform = new Transform2(position, 0, Vector2.One); entity.Attach(transform); return(entity); }
public EfxGenerator(Texture2D texture) { var spriteWidth = 32; var spriteHeight = 32; ObjectTexture = texture; var objectAtlas = TextureAtlas.Create("objectAtlas", ObjectTexture, spriteWidth, spriteHeight); var animationFactory = new SpriteSheetAnimationFactory(objectAtlas); animationFactory.Add("Init", new SpriteSheetAnimationData(new[] { 0 }, 0.1f, false)); animationFactory.Add("Death", new SpriteSheetAnimationData(new[] { 1, 2, 3, 4 }, 0.05f, false)); animationFactory.Add("Smoke", new SpriteSheetAnimationData(new[] { 5, 6, 7, 8, 9, 10 }, 0.12f, false)); ObjectAnimated = new AnimatedSprite(animationFactory, "Init"); ObjectSprite = ObjectAnimated; ObjectSprite.Origin = Vector2.Zero; }
private void CreatePlayersprite() { var texture = _content.Load <Texture2D>("charactersprite"); var atlas = TextureAtlas.Create("characteratlas", texture, 64, 64); var animationfactory = new SpriteSheetAnimationFactory(atlas); animationfactory.Add("spellcastBack", new SpriteSheetAnimationData(new[] { 0, 1, 2, 3, 4, 5, 6 }, isLooping: false)); animationfactory.Add("spellcastLeft", new SpriteSheetAnimationData(new[] { 13, 14, 15, 16, 17, 18, 19 }, isLooping: false)); animationfactory.Add("spellcastFront", new SpriteSheetAnimationData(new[] { 26, 27, 28, 29, 30, 31, 32 }, isLooping: false)); animationfactory.Add("spellcastRight", new SpriteSheetAnimationData(new[] { 39, 40, 41, 42, 43, 44, 45 }, isLooping: false)); animationfactory.Add("thrustBack", new SpriteSheetAnimationData(new[] { 52, 53, 54, 55, 56, 57, 58 }, isLooping: false)); animationfactory.Add("thrustLeft", new SpriteSheetAnimationData(new[] { 65, 66, 67, 68, 69, 70, 71 }, isLooping: false)); animationfactory.Add("thrustFront", new SpriteSheetAnimationData(new[] { 78, 79, 80, 81, 82, 83, 84 }, isLooping: false)); animationfactory.Add("thrustRight", new SpriteSheetAnimationData(new[] { 91, 92, 93, 94, 95, 96, 97 }, isLooping: false)); animationfactory.Add("walkBack", new SpriteSheetAnimationData(new[] { 104, 105, 106, 107, 108, 109, 110 }, isLooping: false)); animationfactory.Add("walkLeft", new SpriteSheetAnimationData(new[] { 117, 118, 119, 120, 121, 122, 123 }, isLooping: false)); animationfactory.Add("walkFront", new SpriteSheetAnimationData(new[] { 130, 131, 132, 133, 134, 135, 136 }, isLooping: false)); animationfactory.Add("walkRight", new SpriteSheetAnimationData(new[] { 143, 144, 145, 146, 147, 148, 149 }, isLooping: false)); animationfactory.Add("slashBack", new SpriteSheetAnimationData(new[] { 156, 157, 158, 159, 160, 161, 162 }, isLooping: false)); animationfactory.Add("slashLeft", new SpriteSheetAnimationData(new[] { 169, 170, 171, 172, 173, 174, 175 }, isLooping: false)); animationfactory.Add("slashFront", new SpriteSheetAnimationData(new[] { 182, 183, 184, 185, 186, 187, 188 }, isLooping: false)); animationfactory.Add("slashRight", new SpriteSheetAnimationData(new[] { 195, 196, 197, 198, 199, 200, 201 }, isLooping: false)); animationfactory.Add("shootBack", new SpriteSheetAnimationData(new[] { 208, 209, 210, 211, 212, 213, 214 }, isLooping: false)); animationfactory.Add("shootLeft", new SpriteSheetAnimationData(new[] { 221, 222, 223, 224, 225, 226, 227 }, isLooping: false)); animationfactory.Add("shootFront", new SpriteSheetAnimationData(new[] { 234, 235, 236, 237, 238, 239, 240 }, isLooping: false)); animationfactory.Add("shootRight", new SpriteSheetAnimationData(new[] { 247, 248, 249, 250, 251, 252, 253 }, isLooping: false)); animationfactory.Add("hurtBack", new SpriteSheetAnimationData(new[] { 260, 261, 262, 263, 264, 265 }, isLooping: false)); animationfactory.Add("hurtLeft", new SpriteSheetAnimationData(new[] { 273, 274, 275, 276, 277, 278 }, isLooping: false)); animationfactory.Add("hurtFront", new SpriteSheetAnimationData(new[] { 286, 287, 288, 289, 290, 291 }, isLooping: false)); animationfactory.Add("hurtRight", new SpriteSheetAnimationData(new[] { 299, 300, 301, 302, 303, 304 }, isLooping: false)); _playerSprite = new AnimatedSprite(animationfactory); _playerSprite.Position = new Vector2(350, 350); //_playerSprite.Play("spellcastBack").IsLooping = true; }
internal FontGlyphs(int lineHeight, params FreeType.Glyph[] glyphs) { LineHeight = lineHeight; var fontAtlas = TextureAtlas.Create(glyphs); Glyphs = glyphs.ToDictionary ( g => g.CharCode, g => new FontGlyph() { TextureAtlas = fontAtlas, TextureAtlasOffset = fontAtlas.GetAtlasPosition(g.CharCode), Width = g.Width, Height = g.Height, BearingX = g.BearingX, BearingY = g.BearingY, Advance = g.Advance } ); }
public override void LoadContent(ContentManager content) { _texture = content.Load <Texture2D>("Textures/s_start_screen"); var spriteWidth = 480; var spriteHeight = 270; var objectTexture = _texture; var objectAtlas = TextureAtlas.Create("objectAtlas", objectTexture, spriteWidth, spriteHeight); var animationFactory = new SpriteSheetAnimationFactory(objectAtlas); animationFactory.Add("Fade", new SpriteSheetAnimationData(new[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }, 0.3f, false)); animationFactory.Add("StartScreen", new SpriteSheetAnimationData(new[] { 10, 11, 12, 13 }, 0.3f)); ObjectAnimated = new AnimatedSprite(animationFactory, "StartScreen"); ObjectSprite = ObjectAnimated; ObjectSprite.Origin = Vector2.Zero; ObjectAnimated.Play("Fade", () => _canPressStart = true); }
public override void LoadContent(ContentManager content) { _texture = content.Load <Texture2D>("Textures/s_load_screen"); _font = content.Load <SpriteFont>("Fonts/f_menu"); var spriteWidth = 480; var spriteHeight = 270; var objectTexture = _texture; var objectAtlas = TextureAtlas.Create("objectAtlas", objectTexture, spriteWidth, spriteHeight); var animationFactory = new SpriteSheetAnimationFactory(objectAtlas); animationFactory.Add("LoadScreen", new SpriteSheetAnimationData(new[] { 0 }, 0.3f)); ObjectAnimated = new AnimatedSprite(animationFactory, "LoadScreen"); ObjectSprite = ObjectAnimated; ObjectSprite.Origin = Vector2.Zero; }
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; }
public override void Load(ContentManager content) { // initiliaze sprite spriteWidth = spriteHeight = 32; objectTexture = content.Load <Texture2D>("Sprites/" + "enemy"); objectAtlas = TextureAtlas.Create("objectAtlas", objectTexture, spriteWidth, spriteHeight); //create animations from sprite sheet animationFactory = new SpriteSheetAnimationFactory(objectAtlas); animationFactory.Add("idle", new SpriteSheetAnimationData(new[] { 0 })); objectAnimated = new AnimatedSprite(animationFactory, "idle"); objectSprite = objectAnimated; objectSprite.Depth = 0.2F; base.Load(content); boundingBoxWidth = 14; boundingBoxHeight = 21; boundingBoxOffset = new Vector2(9, 6); }