Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
385 views
in Technique[技术] by (71.8m points)

libgdx - 手动在GlyphLayout中换行(New line manully in GlyphLayout)

There is a need to start a new line when drawing text manually.

(手动绘制文本时需要开始新的一行。)

But \n does not work.

(但是\n不起作用。)

What am I doing wrong?

(我究竟做错了什么?)

gl=new GlyphLayout();
font=Assets.getFont(10);
gl.setText(font, text, Color.WHITE, cam.getDims().x-cam.getDims().x/10, Align.left, true);
font.draw(sb, gl, -(cam.getDims().x-cam.getDims().x/10)/2, -cam.getDims().y/6);
  ask by Asidert translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

text contains \\n , not \n .

(text包含\\n而不是\n 。)

Replacing \ and n with \n solves this issue.

(更换\n\n解决了这个问题。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...