원근 카메라를 사용하여 스프라이트 배치를 렌더링 할 수 있습니까?
모든 내 스프라이트 (같은 텍스처로로드 된 것)는 같은 크기로 보이지만 카메라가 화면 하단에 약간의 높이로 배치되기를 원하므로 화면 상단 근처에 위치한 스프라이트는 더 작아 보입니다. 지금은 왼쪽에있는 것처럼 보이지만 오른쪽에있는 것처럼 보이기를 원합니다.
예, 아마도 좌표를 약간 조정 / 스케일해야 할 필요가 있지만 spriteBatch.setTransformMatrix를 사용하여 한 번의 호출로 수행 할 수 있습니다. 다음은 작은 예입니다.
public class SpriteBatch3DTest extends GdxTest {
PerspectiveCamera cam;
CameraInputController camController;
SpriteBatch spriteBatch;
Texture texture;
@Override
public void create () {
cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
cam.position.set(0f, 8f, 8f);
cam.lookAt(0,0,0);
cam.near = 0.1f;
cam.far = 300f;
cam.update();
spriteBatch = new SpriteBatch();
camController = new CameraInputController(cam);
Gdx.input.setInputProcessor(camController);
texture = new Texture(Gdx.files.internal("data/badlogic.jpg"));
}
@Override
public void render () {
camController.update();
spriteBatch.setProjectionMatrix(cam.combined);
Gdx.gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
spriteBatch.begin();
spriteBatch.draw(texture, -5f, -5f, 10f, 10f);
spriteBatch.end();
}
@Override
public void dispose () {
spriteBatch.dispose();
texture.dispose();
}
public boolean needsGL20 () {
return true;
}
public void resume () {
}
public void resize (int width, int height) {
}
public void pause () {
}
}
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다