public void LoadContent() { // Load animated textures. SpriteTextures.Add(Level.Content.Load <Texture2D>("Sprites/Player/player")); Animation anim = new Animation(); anim.LoadAnimation("Idle", 0, new List <int> { 0, 11, 0, 12 }, 7, true); SpriteAnimations.Add("Idle", anim); anim = new Animation(); anim.LoadAnimation("Walking", 0, new List <int> { 0, 1, 2, 3, 4, 5, 6 }, 7, true); SpriteAnimations.Add("Walking", anim); anim = new Animation(); anim.LoadAnimation("Jump", 0, new List <int> { 7, 8, 9, 10, 9, 8, 7 }, 20, false); anim.AnimationCallBack(JumpAnimEnd); SpriteAnimations.Add("Jump", anim); // Calculate bounds within texture size. // subtract 4 from width and height to remove a 2px buffer // around the player. int width = FrameWidth - 4; int left = (FrameWidth - width) / 2; int height = FrameHeight - 4; int top = FrameHeight - height; localBounds = new Rectangle(left, top, width, height); anim = new Animation(); anim.LoadAnimation("Dead", 0, new List <int> { 13, 14, 15 }, 6, false); anim.AnimationCallBack(DeadAnimEnd); SpriteAnimations.Add("Dead", anim); }
public void LoadContent(string _enemy) { string enemyString = string.Empty; switch (_enemy) { case "e": enemyString = "Sprites/Enemies/muffinman"; break; default: enemyString = "Sprites/Enemies/muffinman"; break; } // Load animated textures. Texture2D tex = Level.Content.Load <Texture2D>(enemyString); if (!SpriteTextures.Contains(tex)) { SpriteTextures.Add(tex); } Animation anim = new Animation(); anim.LoadAnimation("Walk", 0, new List <int> { 0, 1 }, 4, true); SpriteAnimations.Add("Walk", anim); anim = new Animation(); anim.LoadAnimation("Dead", 0, new List <int> { 2, 3, 4, 5 }, 36, false); anim.AnimationCallBack(DeadAnimEnd); SpriteAnimations.Add("Dead", anim); // Calculate bounds within texture size. // subtract 10 from width and height to remove a 5px buffer // around the enemy. int width = FrameWidth - 10; int left = (FrameWidth - width) / 2; int height = FrameHeight - 10; int top = FrameHeight - height; localBounds = new Rectangle(left, top, width, height); SpriteAnimations[currentAnim].ResetPlay(); }
public void LoadContent(string _collectable) { string sheetString = string.Empty; switch (_collectable) { case "s": sheetString = "Sprites/Collectables/scribbles"; colorOffset = Color.Black; break; case "S": sheetString = "Sprites/Collectables/scribbles"; colorOffset = Color.Gold; break; default: sheetString = "Sprites/Collectables/scribbles"; colorOffset = Color.White; break; } // Load animated textures. Texture2D tex = Level.Content.Load <Texture2D>(sheetString); if (!SpriteTextures.Contains(tex)) { SpriteTextures.Add(tex); } Animation anim = new Animation(); anim.LoadAnimation("Idle", 0, new List <int> { 0, 1, 2, 3 }, 16, true); SpriteAnimations.Add("Idle", anim); // Calculate bounds within texture size. // subtract 4 from height to remove a 2px buffer // around the collectable. int width = FrameWidth; int left = (FrameWidth - width) / 2; int height = FrameHeight - 4; int top = FrameHeight - height; localBounds = new Rectangle(left, top, width, height); SpriteAnimations[currentAnim].ResetPlay(); }
public void LoadContent(string _collectable) { string sheetString = string.Empty; switch (_collectable) { case "s": sheetString = "Sprites//Collectable/scribbles"; colorOffset = Color.Black; pointsAwarded = 500; break; case "S": sheetString = "Sprites/Collectable/scribbles"; colorOffset = Color.Gold; pointsAwarded = 1000; break; default: sheetString = "Sprites/Collectable/scribbles"; colorOffset = Color.White; break; } Texture2D tex = Level.Content.Load <Texture2D>(sheetString); if (!SpriteTextures.Contains(tex)) { SpriteTextures.Add(tex); } Animation anim = new Animation(); anim.LoadAnimation("Idle", 0, new List <int> { 0, 1, 2, 3 }, 16, true); SpriteAnimations.Add("Idle", anim); int width = FrameWidth; int left = (FrameWidth - width) / 2; int height = FrameHeight - 4; int top = FrameHeight - height; localBounds = new Rectangle(left, top, width, height); SpriteAnimations[currentAnim].ResetPlay(); }
private void LoadAnimations() { Animation anim = new Animation(); anim.LoadAnimation("Idle", new List <int> { 0, 0, 6, 6, 7, 7, 7, 8, 8, 8 }, 3, true); SpriteAnimations.Add("Idle", anim); anim = new Animation(); anim.LoadAnimation("Walking", new List <int> { 9, 12, 9, 10 }, 5, true); SpriteAnimations.Add("Walking", anim); anim = new Animation(); anim.LoadAnimation("Jump", new List <int> { 2 }, 1, true); SpriteAnimations.Add("Jump", anim); anim = new Animation(); anim.LoadAnimation("Land", new List <int> { 2, 3, 3, 3, 3 }, 10, false); anim.AnimationCallBack(() => { currentAnim = "Idle"; SpriteAnimations[currentAnim].ResetPlay(); }); SpriteAnimations.Add("Land", anim); anim = new Animation(); anim.LoadAnimation("Dead", new List <int> { 0, 4, 4, 5, 5, 5, 5, 5, 16, 16, 16 }, 3, false); anim.AnimationCallBack(() => DeadAnimationEnded = true); SpriteAnimations.Add("Dead", anim); int width = FrameWidth - 48; int left = (FrameWidth - width) / 2; int height = FrameHeight - 23; int top = FrameHeight - height - 10; localBounds = new Rectangle(left, top, width, height); SpriteAnimations[currentAnim].ResetPlay(); }
public void LoadContent() { // Load animated textures. SpriteTextures.Add(Level.Content.Load <Texture2D>("Sprites/Player/player")); Animation anim = new Animation(); anim.LoadAnimation("Idle", 0, new List <int> { 0, 11, 0, 12 }, 7, true); SpriteAnimations.Add("Idle", anim); anim = new Animation(); anim.LoadAnimation("Walking", 0, new List <int> { 9, 12, 9, 10 }, 7, true); SpriteAnimations.Add("Walking", anim); anim = new Animation(); anim.LoadAnimation("Jump", 0, new List <int> { 7, 8, 9, 10, 9, 8, 7 }, 20, false); anim.AnimationCallBack(JumpAnimEnd); SpriteAnimations.Add("Jump", anim); anim = new Animation(); anim.LoadAnimation("Dead", 0, new List <int> { 13, 14, 15 }, 6, false); anim.AnimationCallBack(DeadAnimEnd); SpriteAnimations.Add("Dead", anim); int width = FrameWidth - 4; int left = (FrameWidth - width) / 2; int height = FrameHeight - 4; int top = FrameHeight - height; localBounds = new Rectangle(left, top, width, height); }