Otter - 文本渲染不起作用
Otter - text rendering not works
我制作了使用 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);
}
方法已执行,未抛出异常,但未呈现,我看不到文本。
我有一个答案。
文本 class 未渲染,因为它未添加到场景中。
要将其添加到场景中,我们需要创建一个实体,并为其添加文本组件。
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);
我制作了使用 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);
}
方法已执行,未抛出异常,但未呈现,我看不到文本。
我有一个答案。 文本 class 未渲染,因为它未添加到场景中。 要将其添加到场景中,我们需要创建一个实体,并为其添加文本组件。
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);