Clone() public method

Returns a clone of this instance.
Attachments are not cloned. The new clone will not have any parents or children.
public Clone ( ) : Sprite
return Sprite
Ejemplo n.º 1
0
        /// <summary>
        /// The reference Sprite is cloned here because some things may change on the Sprite after it is deleted; 
        /// specifically its attachments.
        /// </summary>
        /// <param name="referenceSprite">Reference to the Sprite that is being deleted.</param>
		public DeleteSprite(Sprite referenceSprite)
		{
			 referenceObject = referenceSprite.Clone();

			for(int i = 0; i < referenceSprite.Children.Count; i++)
				((Sprite)referenceObject).Children.AddOneWay(referenceSprite.Children[i]);
			
			
		}
Ejemplo n.º 2
0
        /// <summary>
        /// The reference Sprite is cloned here because some things may change on the Sprite after it is deleted;
        /// specifically its attachments.
        /// </summary>
        /// <param name="referenceSprite">Reference to the Sprite that is being deleted.</param>
        public DeleteSprite(Sprite referenceSprite)
        {
            referenceObject = referenceSprite.Clone();

            for (int i = 0; i < referenceSprite.Children.Count; i++)
            {
                ((Sprite)referenceObject).Children.AddOneWay(referenceSprite.Children[i]);
            }
        }
Ejemplo n.º 3
0
        public Scene Clone()
        {
            Scene scene = new Scene();

            #region Create the Sprites
            for (int i = 0; i < mSprites.Count; i++)
            {
                Sprite sprite = mSprites[i];
                scene.mSprites.Add(sprite.Clone());
            }

            for (int i = 0; i < mSprites.Count; i++)
            {
                Sprite thisSprite = mSprites[i];

                if (thisSprite.Parent != null)
                {
                    Sprite otherSprite = scene.mSprites[i];

                    otherSprite.AttachTo(
                        scene.mSprites.FindByName(thisSprite.Parent.Name), false);
                }
            }

            #endregion

            #region Create the SpriteGrids
            for (int i = 0; i < mSpriteGrids.Count; i++)
            {
                SpriteGrid spriteGrid = mSpriteGrids[i];
                scene.mSpriteGrids.Add(spriteGrid.Clone());
            }
            #endregion

            #region Create and Attach the SpriteFrames
            for (int i = 0; i < mSpriteFrames.Count; i++)
            {
                SpriteFrame spriteFrame = mSpriteFrames[i];
                scene.mSpriteFrames.Add(spriteFrame.Clone());
            }
            #endregion

            #region Create and attach the Texts

            for (int i = 0; i < mTexts.Count; i++)
            {
                Text text = mTexts[i];
                scene.mTexts.Add(text.Clone());
            }

            for (int i = 0; i < mTexts.Count; i++)
            {
                Text thisText = mTexts[i];

                if (thisText.Parent != null)
                {
                    Text otherText = scene.mTexts[i];
                    otherText.AttachTo(
                        scene.mTexts.FindByName(thisText.Parent.Name), false);
                }
            }

            #endregion

            scene.Name = Name;

            return(scene);
        }