public PlayState(GameStateManager gsm) {
super(gsm);
bird = new Bird(50, 300);
cam.setToOrtho(false, GameMenu.WIDTH/2, GameMenu.HEIGHT/2);
bg = new Texture("bg.png");
}
@Override
public void render(SpriteBatch sb) {
sb.setProjectionMatrix(cam.combined);
sb.begin();
sb.draw(bg, cam.position.x- (cam.viewportWidth/2), 0);
sb.draw(bird.getTexture(), bird.getPosition().x, bird.getPosition().y);
sb.end();
}
在添加setProjectionMatrix并绘制背景图像时,它的显示尺寸比我的Android屏幕小
我刚刚开始使用Libgdx框架进行游戏编程
我已经在使用这些解决方案,但是我的项目没有效果
https://gamedev.stackexchange.com/questions/120722/screensize-vs-worldsize
答案 0 :(得分:0)
您有视口吗?如果是,请尝试sb.draw(bird.getTexture(), bird.getPosition().x, bird.getPosition().y, vievport.getWorldWidth(), viewport.getWorldHeight());