我做了一个方法,用水龙头(2D游戏渲染库使用SFML.NET)绘制文本,.But方法不能正常工作,文本不能被渲染。代码:
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);
}方法已执行,异常未抛出,但它未呈现,我看不到文本。
发布于 2019-01-25 15:40:03
我有答案了。文本类不渲染,因为它没有添加到场景中。要将其添加到场景中,我们需要创建一个实体,并向其添加文本组件。
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);https://stackoverflow.com/questions/54333473
复制相似问题