示例#1
0
        /// <summary>
        /// Render the texture and text to the screen.
        /// </summary>
        /// <param name="data"></param>
        public void Render(object data)
        {
            if (Texture != null)
            {
                ScreenSpaceQuad quad = ScreenSpaceQuad.GetInstance();
                quad.Render(Texture,
                            Vector4.One,
                            new Vector2(Center.X - Width / 2, Center.Y - Height / 2),
                            new Vector2(Width, Height),
                            @"TexturedRegularAlpha");
            }

            if (!string.IsNullOrEmpty(Text))
            {
                SpriteBatch batch = UI2D.Shared.SpriteBatch;

                Vector2 stringSize = Font().MeasureString(TextHelper.FilterInvalidCharacters(text));
                Point   textPos    = new Point(
                    TextCenter.X - (int)(stringSize.X * 0.5f + 0.5f),
                    TextCenter.Y);

                batch.Begin();
                TextHelper.DrawStringWithShadow(Font,
                                                batch,
                                                textPos.X, textPos.Y,
                                                text,
                                                Color.White,
                                                Color.DimGray,
                                                false);
                batch.End();
            }
        }
示例#2
0
        public static ScreenSpaceQuad GetInstance()
        {
            if (instance == null)
            {
                instance = new ScreenSpaceQuad();
            }

            return(instance);
        }   // end of ScreenSpaceQuad GetInstance()