public static void CacheQueued() { int counter = 0; //evitar que o jogo se prenda tentando criar muitas texturas de uma só vez while (QueuedStrings.Count > 0 && counter < 5) { AddToCache(QueuedStrings.Dequeue()); counter++; } if (counter == 5) { counter = 0; } }
public static bool StringToTexture(string text, out Texture2D texture) { if (spriteBatch != null && !string.IsNullOrEmpty(text)) { if (!CachedTextures.ContainsKey(text)) { QueuedStrings.Enqueue(text); } else { texture = CachedTextures[text]; return(true); } } texture = new Texture2D(spriteBatch.GraphicsDevice, 1, 1); return(false); }