コード例 #1
0
        public static Text AddText(string displayText, Layer layer)
        {
            if (layer == null)
            {
                return(AddText(displayText, DefaultFont));
            }
            else
            {
#if !SILVERLIGHT
                if (DefaultFont == null)
                {
                    throw new System.InvalidOperationException("Cannot create Text object because the TextManager's DefaultFont has not been set.");
                }
#endif
                Text text = new Text(DefaultFont);
                text.DisplayText = displayText;
                if (layer.CameraBelongingTo != null)
                {
                    text.SetPixelPerfectScale(layer.CameraBelongingTo);
                }
                else
                {
                    text.SetPixelPerfectScale(SpriteManager.Camera);
                }
                layer.Add(text);
                // Don't add the text to mDrawnTexts since it's drawn as part of the layer.

#if DEBUG
                if (mAutomaticallyUpdatedTexts.Contains(text))
                {
                    throw new InvalidOperationException("Can't add the text to the Automatically Updated (Managed) Text list because it's already there.  This error is here to prevent you from double-adding Texts.");
                }
#endif

                mAutomaticallyUpdatedTexts.Add(text);
                return(text);
            }
        }
コード例 #2
0
        public static void AddToLayer(Text text, Layer layerToAddTo)
        {
            if (layerToAddTo == null)
            {
                AddText(text);
            }
            else
            {
                layerToAddTo.Add(text);
                if (text.ListsBelongingTo.Contains(mDrawnTexts))
                {
                    mDrawnTexts.Remove(text);
                }

                if (text.ListsBelongingTo.Contains(mAutomaticallyUpdatedTexts) == false)
                {
                    // The Text is not updated.  That means
                    // it was instantiated outside of the TextManager.  Add it here as an
                    // automatically updated Text
                    mAutomaticallyUpdatedTexts.Add(text);
                }
            }
        }
コード例 #3
0
        static public Text AddText(Text textToAdd, Layer layerToAddTo)
        {
            if (layerToAddTo == null)
            {
                return(AddText(textToAdd));
            }
            else
            {
                if (textToAdd.ListsBelongingTo.Contains(mDrawnTexts))
                {
                    mDrawnTexts.Remove(textToAdd);
                }

                layerToAddTo.Add(textToAdd);

                if (textToAdd.ListsBelongingTo.Contains(mAutomaticallyUpdatedTexts) == false)
                {
                    mAutomaticallyUpdatedTexts.Add(textToAdd);
                }
                // otherwise no need to add it.

                return(textToAdd);
            }
        }