Debug sprite sharing

This commit is contained in:
Tim Young 2017-09-12 07:45:04 -05:00
parent c43069eec7
commit 4d49f58809
2 changed files with 9 additions and 3 deletions

View File

@ -252,7 +252,7 @@ namespace SpriteLibrary
/// </summary>
public bool MirrorVertically = false;
SpriteController MySpriteController;
internal SpriteController MySpriteController;
private bool _Destroying = false;
/// <summary>
/// If the Sprite is in the middle of being Destroyed, this is set to true. When a Sprite is

View File

@ -976,6 +976,7 @@ namespace SpriteLibrary
{
//If we get here, we do not have it in our list. Add it to this controller and then return it
AddSprite(Found);
//Console.WriteLine("Found A Sprite in another controller:" + Found.SpriteName);
return Found;
}
}
@ -1003,6 +1004,7 @@ namespace SpriteLibrary
/// <param name="SpriteToAdd">The sprite to add to the sprite-controller</param>
public void AddSprite(Sprite SpriteToAdd)
{
SpriteToAdd.MySpriteController = this;
Sprites.Add(SpriteToAdd);
AddSpriteToLinkedControllers(SpriteToAdd);
SortSprites();
@ -1016,8 +1018,12 @@ namespace SpriteLibrary
{
if (SpriteToAdd.SpriteName == "") return; //We only add named sprites
Sprite found = SpriteFromName(SpriteToAdd.SpriteName);
if(found == null)
Sprites.Add(SpriteToAdd);
if (found == null)
{
Sprite Clone = new Sprite(SpriteToAdd,true);
Clone.MySpriteController = this;
Sprites.Add(Clone);
}
}
/// <summary>