【问题标题】:Otter - text rendering not works水獭 - 文本渲染不起作用
【发布时间】:2019-06-17 09:52:00
【问题描述】:

我制作了使用 Otter 绘制文本的方法(使用 SFML.NET 的 2D 游戏渲染库)。但方法不正确,文本未渲染。 代码:

    public static void DrawText(string Text,string Font,int Size,VXG_Color 
                                                                         clr)
    {
        Text t = new Text(Text,Font,Size);
        t.Color = VXGColor(clr);
        t.Render(0f,0f);
        t.Visible = true;
    }

使用方法:

static void Main(string[] args)
 {
   DrawText("hello", @"C:\Users\serge\Downloads\DarkDemo\DarkDemo\bin\kongtext.ttf", 72, Rendering.VXG_Color.Orange);
 }

方法已执行,未抛出异常,但未呈现,我看不到文本。

【问题讨论】:

    标签: c# rendering sfml text-rendering sfml.net


    【解决方案1】:

    我有一个答案。 文本类未渲染,因为它未添加到场景中。 要将其添加到场景中,我们需要创建一个实体,并为其添加文本组件。

    Game g = new Game();
    g.Color = Color.Black;
    Scene scn = new Scene();
    Text t = new Text("Text","Font",16);
    Entity ent = new Entity();
    ent.AddGraphics(t);
    scn.Add(ent);
    g.Start(scn);
    

    【讨论】:

      猜你喜欢
      • 2012-03-04
      • 2015-01-09
      • 1970-01-01
      • 2013-05-02
      • 2016-02-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多