public Text(float x, float y, string content, string fontName) : base(x, y, 1, 1) { Content = content; font = AssetManager.GetFont(fontName); Scale = new Vector2(1, 1); transform = Matrix.Identity; shader = new BMFontShader(Color.White, Color.Black, Color.Transparent); literalBounds = new MAABB(X, Y, Width, Height) { Color = PICO8.GrassGreen }; exactBounds = new MQuad(X, Y, Width, Height) { Color = PICO8.BloodRed }; broadBounds = new MAABB(X, Y, Width, Height) { Color = PICO8.FleshPink }; spriteCollection = new SpriteCollection(); CreateText(); }
private static Sprite[] Create(Vector3 position, string text, BMFont font, BMFontShader shader) { Sprite[] sprites = new Sprite[text.Length]; float xOffset = position.X; for (int i = 0; i < text.Length; i++) { char character = text.Substring(i, 1).ToCharArray()[0]; BMFontCharacter characterData = font.GetCharacterData(character); sprites[i] = Sprite.Create() .SetTexture(font.GetPage(characterData.Page)) .SetSampleRegion(characterData.ImageRegion) .SetRenderOptions(new RenderOptions() { DepthStencilState = DepthStencilState.None, Effect = shader.Effect }) .SetPosition(xOffset + characterData.XOffset, position.Y - characterData.YOffset, position.Z); xOffset += characterData.XAdvance; } return(sprites); }
static DebugManager() { camera = new OrthographicCamera() .SetProjection(WindowManager.WindowWidth, WindowManager.WindowHeight, 0.25f, 8); camera.SetPosition(WindowManager.WindowWidth * 0.5f, -WindowManager.WindowHeight * 0.5f, 1); WindowManager.WindowResize += HandleResize; font = AssetManager.GetFont("Relatus_Probity"); fontShader = new BMFontShader(); }
public static void DrawText(float x, float y, string text, BMFont font, BMFontShader fontShader, Camera camera) { DrawSpriteCollection(BatchExecution.DrawElements, 1, ImText.Create(x, y, text, font, fontShader), camera); }
public static Sprite[] Create(float x, float y, string text, BMFont font, BMFontShader shader) { return(Create(new Vector3(x, y, 0), text, font, shader)); }