0
LibGDX에서 글꼴 그리기에 문제가 있습니다. 창 크기를 조정할 수 있고 텍스트를 읽을 수 있기를 원합니다. 기본 응용 프로그램 방향이 같은 세로입니다 :LibGDX 크기 조정 창 글꼴 그림
내가 내 응용 프로그램에서 풍경을 시작하기 전에 변경할 수 있습니다 모든 것이 잘 작동 :
그러나 세로에서 가로로 응용 프로그램의 크기를 조정할 수 있기를 원합니다. . 나는 그것을 (때 예를 들어, "초상"에서 "풍경"에서하지만, 텍스트가 뻗어있다
에 대한 나의 코드는 처음부터 단지 코드)입니다 (렌더링과 기능의 크기를 조정 :.
? 내가 나쁜 일을하고 무엇public void render() {
try
{
Gdx.gl.glClearColor(1, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
//background draw
//_spriteBatch.begin();
//_spriteBatch.draw(background, 0, 0);
//_spriteBatch.end();
_spriteBatch.begin();
//sprite.draw(batch);
elapsedTime += Gdx.graphics.getDeltaTime();
_spriteBatch.draw(animation.getKeyFrame(elapsedTime, true), 0, 0);
_spriteBatch.end();
//content draw
_spriteBatch.begin();
if(!_isLandscape)
_spriteBatch.draw(img, 20, 210, 30, 45);
//NameDayDOM nameDayDOM = new NameDayDOM();
NameDaySAX nameDaySAX = new NameDaySAX();
name = nameDaySAX.getCurrentName(_serviceProvider.getAssetHandleResolver().resolve("namesday.xml").file());
//II _font.draw(_spriteBatch, "Happy Name Day, dear " + name, Gdx.graphics.getWidth()/7.0f, Gdx.graphics.getHeight()/2.0f);
if(!_isLandscape) {
BitmapFont.TextBounds bounds = _font40.getBounds("Happy Name Day");
_font40.draw(_spriteBatch, "Happy Name Day", (Gdx.graphics.getWidth()-bounds.width)/5.0f, Gdx.graphics.getHeight() - 120);
bounds = _font30.getBounds("dear" + name);
_font30.draw(_spriteBatch, "dear " + name, (Gdx.graphics.getWidth()-bounds.width)/3.2f, Gdx.graphics.getHeight() - 200);
bounds = _font23.getBounds("Post picture from this venue");
_font23.draw(_spriteBatch, "Post picture from this venue", (Gdx.graphics.getWidth()-bounds.width)/9.0f, Gdx.graphics.getHeight()/4.7f);
bounds = _font23.getBounds("and tell to world,");
_font23.draw(_spriteBatch, "and tell to world,", (Gdx.graphics.getWidth()-bounds.width)/7.0f, Gdx.graphics.getHeight()/5.5f);
bounds = _font23.getBounds("that you are enjoying your NameDay!");
_font23.draw(_spriteBatch, "that you are enjoying your NameDay!", (Gdx.graphics.getWidth()-bounds.width)/2.0f, Gdx.graphics.getHeight()/6.5f);
}else{
BitmapFont.TextBounds bounds = _font40.getBounds("Happy Name Day");
_font40.draw(_spriteBatch, "Happy Name Day", (Gdx.graphics.getWidth()-bounds.width)/14.0f, Gdx.graphics.getHeight()/1.7f);
bounds = _font30.getBounds("dear" + name);
_font30.draw(_spriteBatch, "dear " + name, (Gdx.graphics.getWidth()-bounds.width)/11.0f, Gdx.graphics.getHeight()/2.0f);
bounds = _font23.getBounds("Post picture from this venue");
_font23.draw(_spriteBatch, "Post picture from this venue", (Gdx.graphics.getWidth()-bounds.width)/14.0f, Gdx.graphics.getHeight()/4.7f);
bounds = _font23.getBounds("and tell to world,");
_font23.draw(_spriteBatch, "and tell to world,", (Gdx.graphics.getWidth()-bounds.width)/11.0f, Gdx.graphics.getHeight()/5.5f);
bounds = _font23.getBounds("that you are enjoying your NameDay!");
_font23.draw(_spriteBatch, "that you are enjoying your NameDay!", (Gdx.graphics.getWidth()-bounds.width)/9.0f, Gdx.graphics.getHeight()/6.5f);
}
}
catch(RuntimeException e)
{
_log.error("Exception on render: " + e);
_serviceProvider.getAppStatusListener().onStateChanged(AppState.Error);
}
finally {
_spriteBatch.end();
}
}
@Override
public void resize(int width , int height){
try {
System.out.println(width + " " + height);
if (height > width) {
_isLandscape = false;
} else {
_isLandscape = true;
}
}catch(Exception ex){
}
}
는 텍스트의 레이아웃은 창 크기를 조정 한 후 변경되지 않는 이유
감사합니다. OrtographicCamera를 사용해야합니다. 그러나 나는 어떤면에서 확신이 들지 않습니다. 제발 샘플 좀 줄래? 텍스트 문자열을 올바르게 크기를 조정 한 후에 그려야합니다. –
제발, 이것에 대한 모든 업데이 트가? –
https://github.com/libgdx/libgdx/wiki/Orthographic-camera – Lestat