/// <summary> /// Clone this sprite manager and all its sprites. /// </summary> /// <returns>A clone of this sprite manager.</returns> public SpriteManager Clone() { //Create the clone. SpriteManager manager = new SpriteManager(); //Clone the properties. manager.ContentManager = _ContentManager; //Clone the sprites. foreach (Sprite sprite in _Sprites) { //Create the cloned sprite. Sprite sClone = new Sprite(manager, sprite.Name); //Clone the properties. sClone.Position = sprite.Position; sClone.TimePerFrame = sprite.TimePerFrame; sClone.Scale = sprite.Scale; sClone.Depth = sprite.Depth; sClone.Rotation = sprite.Rotation; sClone.PositionOffset = sprite.PositionOffset; sClone.OrbitOffset = sprite.OrbitOffset; sClone.RotationOffset = sprite.RotationOffset; sClone.Tag = sprite.Tag; sClone.Transparence = sprite.Transparence; sClone.Visibility = sprite.Visibility; sClone.Orientation = sprite.Orientation; //Clone the frames. foreach (Frame frame in sprite.Frames) { //Create the cloned frame. Frame fClone = new Frame(frame.Path, frame.Width, frame.Height); //Clone the properties. fClone.Path = frame.Path; fClone.Width = frame.Width; fClone.Height = frame.Height; fClone.Origin = frame.Origin; fClone.Texture = frame.Texture; //Add the cloned frame to the cloned sprite. sClone.AddFrame(fClone); } //Add the cloned sprite to the cloned manager. manager.Add(sClone); } //Make sure that all sprites have been properly activated. manager.ManageSprites(); //Return the clone. return manager; }
/// <summary> /// Add a sprite. /// </summary> /// <param name="manager">The manager to add the sprite to.</param> /// <param name="name">The name of the sprite.</param> /// <param name="texture">The texture of the sprite.</param> /// <param name="position">The position of the sprite.</param> /// <param name="timePerFrame">The time per frame.</param> /// <param name="scale">The scale of the sprite.</param> /// <param name="depth">The depth of the sprite.</param> /// <param name="rotation">The rotation of the sprite.</param> /// <param name="offset">The offset of the sprite.</param> /// <param name="tag">The tag of the sprite, that is something to link it with.</param> /// <param name="origin">The origin of the sprite.</param> public Sprite AddSprite(SpriteManager manager, string name, Texture2D texture, Vector2 position, float timePerFrame, Vector2 scale, int depth, float rotation, float offset, string tag, Vector2 origin) { //Create the sprite and add it to the manager. Sprite sprite = manager.Add(new Sprite(manager, name)); //Set the properties. sprite.Position = position; sprite.TimePerFrame = timePerFrame; sprite.Scale = scale; sprite.Depth = depth; sprite.Rotation = rotation; sprite.PositionOffset = offset; sprite.Tag = tag; //Add a frame to the sprite. sprite.AddFrame(texture, origin); manager.ManageSprites(); //Return the sprite. return sprite; }
/// <summary> /// Add a sprite to a manager. /// </summary> /// <param name="manager">The manager to add the sprite to.</param> /// <param name="name">The name of the sprite.</param> /// <param name="path">The path of the texture.</param> /// <param name="position">The position of the sprite.</param> /// <param name="orbitRotation">The orbit rotation of the sprite.</param> /// <param name="timePerFrame">The time per frame.</param> /// <param name="scale">The scale of the sprite.</param> /// <param name="depth">The depth of the sprite.</param> /// <param name="rotation">The rotation of the sprite.</param> /// <param name="tag">The tag of the sprite, that is something to link it with.</param> /// <param name="offset">The offset of the sprite.</param> public Sprite AddSprite(SpriteManager manager, string name, string path, Vector2 position, float orbitRotation, float timePerFrame, Vector2 scale, int depth, float rotation, string tag, float offset) { //Create the sprite. Sprite sprite = new Sprite(manager, name); //Set the properties. sprite.Position = Helper.CalculateOrbitPosition(position, orbitRotation, offset); sprite.TimePerFrame = timePerFrame; sprite.Scale = scale; sprite.Depth = depth; sprite.Rotation = rotation; sprite.PositionOffset = offset; sprite.RotationOffset = Helper.SubtractAngles(rotation, orbitRotation); //Add a frame to the sprite. sprite.AddFrame(path); //Add the sprite to the manager. manager.Add(sprite); manager.ManageSprites(); //Return the sprite. return sprite; }
/// <summary> /// Add a sprite to a manager. /// </summary> /// <param name="manager">The manager to add the sprite to.</param> /// <param name="name">The name of the sprite.</param> /// <param name="path">The path of the texture.</param> /// <param name="rotationOffset">The rotation offset of the sprite.</param> /// <param name="tag">The tag of the sprite, that is something to link it with.</param> public Sprite AddSprite(SpriteManager manager, string name, string path, float rotationOffset, string tag) { //Create the sprite. Sprite sprite = new Sprite(manager, name); //Set the properties. sprite.Tag = tag; sprite.RotationOffset = rotationOffset; //Add a frame to the sprite. sprite.AddFrame(path); //Add the sprite to the manager. manager.Add(sprite); manager.ManageSprites(); //Return the sprite. return sprite; }
/// <summary> /// Add a sprite to a manager. /// </summary> /// <param name="manager">The manager to add the sprite to.</param> /// <param name="name">The name of the sprite.</param> /// <param name="path">The path of the texture.</param> /// <param name="origin">The origin of the sprite.</param> /// <returns>The recently added sprite.</returns> public Sprite AddSprite(SpriteManager manager, string name, string path, Vector2 origin) { //Create the sprite. Sprite sprite = new Sprite(manager, name); //Add a frame to the sprite. sprite.AddFrame(path, origin); //Add the sprite to the manager. manager.Add(sprite); manager.ManageSprites(); //Return the sprite. return sprite; }
/// <summary> /// Add a sprite. /// </summary> /// <param name="manager">The manager to add the sprite to.</param> /// <param name="name">The name of the sprite.</param> /// <param name="texture">The texture of the sprite.</param> public Sprite AddSprite(SpriteManager manager, string name, Texture2D texture) { //Create the sprite. Sprite sprite = new Sprite(manager, name); //Add a frame to the sprite. sprite.AddFrame(texture); //Add the sprite to the manager. manager.Add(sprite); manager.ManageSprites(); //Return the sprite. return sprite; }