public override void AddAnimation(string name, Animation animation) { for (int i = 0; i < layers.Count; i++) { layers[i].sprite.AddAnimation(name, animation); } }
//Adds an animation to the animation list. public virtual void AddAnimation(string name, Animation animation) { this.animations.Add(name, animation); }
public void StartGame() { //-----------------Creating a normal sprite---------------- //Create the background Sprite backgroundSprite = SpriteEngine.CreateSprite("background"); backgroundSprite.depth = 800; //---------------Creating a sprite with position-------------- //Create a building at (200, 200) Sprite buildingSprite = SpriteEngine.CreateSprite("building", 200, 50, 1f); buildingSprite.depth = -(50 + buildingSprite.GetImage().Height); //Set its depth equal to the negative value of the Y of the bottom of the sprite. //(Note that the engine supports transparency, mspaint just doesn't.) //---------------Creating a multi-layer sprite--------------- //Create layers to build the player with Sprite heads = new Sprite( new Texture2D[] { SpriteEngine.textures["head1"], SpriteEngine.textures["head2"], SpriteEngine.textures["head3"] }, new string[] { "head1", "head2", "head3" }); Sprite bodies = new Sprite( new Texture2D[] { SpriteEngine.textures["body1"], SpriteEngine.textures["body2"], SpriteEngine.textures["body3"] }, new string[] { "body1", "body2", "body3" }); Sprite legs = new Sprite( new Texture2D[] { SpriteEngine.textures["legs1"], SpriteEngine.textures["legs2"], SpriteEngine.textures["legs3"] }, new string[] { "legs1", "legs2", "legs3" }); //Create the player at (500, 650) player = SpriteEngine.CreateLayeredSprite(new Sprite[] { heads, bodies, legs }, new string[] { "head", "body", "legs" }, 500, 650); //--------------Creating an animated sprite--------------- //Create an animated sign at (700, 400) Sprite sign = SpriteEngine.CreateMultiSprite(new string[] { "Anim1", "Anim2", "Anim3" }, 700, 300, 1f); sign.depth = -(300 + sign.GetImage().Height); //Set depth Animation anim = new Animation("text", "Anim1", 3, 100); sign.AddAnimation(anim.name, anim); sign.ChangeAnimation("text"); //-------------Creating a GText------- instructionText = SpriteEngine.CreateGText("Arrows to move around, Q to change head, W to change body, E to change legs, Enter to fake loading screen.", 300, 250); instructionText.depth = -250; //It will be behind the building //-----------Setting a load screen---- //Note: Loading support is very basic and it kinda sucks. Build your own for fancy loading. Sprite loadSprite = new Sprite(SpriteEngine.textures["loading"], Vector2.Zero); SpriteEngine.loadingGObjects.Add(loadSprite); }