diff --git a/SpriteLibrary/SpriteController.cs b/SpriteLibrary/SpriteController.cs index 04fbb24..2e613bc 100644 --- a/SpriteLibrary/SpriteController.cs +++ b/SpriteLibrary/SpriteController.cs @@ -964,9 +964,34 @@ namespace SpriteLibrary if (OneSprite.SpriteName == Name) { return OneSprite; } } + //If we have not found one on this controller, get it from another controller + foreach(SpriteController SC in LinkedControllers) + { + Sprite Found = SC.SpriteFromNameInternal(Name); + if (Found != null) + { + //If we get here, we do not have it in our list. Add it to this controller and then return it + AddSprite(Found); + return Found; + } + } return null; } + /// + /// The internal SpriteFromName does not check the linked controllers. Keeps us from entering into an endless loop + /// + /// + /// + internal Sprite SpriteFromNameInternal(string Name) + { + foreach (Sprite OneSprite in Sprites) + { + if (OneSprite.SpriteName == Name) + { return OneSprite; } + } + return null; + } /// /// Add the specified sprite to the list of sprites we know about. You usually do not need to do this. /// Sprites add themselves to the controller when you create a new sprite.