Java 如何在引擎场景中居中背景
是否有一个公式可用于将安德林相机中的背景居中 我的相机是特定设备上的屏幕大小,我用这个Java 如何在引擎场景中居中背景,java,android,andengine,Java,Android,Andengine,是否有一个公式可用于将安德林相机中的背景居中 我的相机是特定设备上的屏幕大小,我用这个 final Display display = getWindowManager().getDefaultDisplay(); CAMERA_WIDTH = display.getWidth(); CAMERA_HEIGHT = display.getHeight(); int x = //formula to center background in camera or screen on the X
final Display display = getWindowManager().getDefaultDisplay();
CAMERA_WIDTH = display.getWidth();
CAMERA_HEIGHT = display.getHeight();
int x = //formula to center background in camera or screen on the X axis
int y = //formula to center background in camera or screen on the Y axis
对于我的SpriteBackground,我如何计算出x和y在相机中的中心位置
x和y是这样提供的
Sprite sprite = new Sprite(x,y,TextureRegion);
这将使雪碧置于场景中间。如果相机不移动,它也将是相机的中心(因此屏幕)
这将使雪碧置于场景中间。如果相机不移动,它也将成为相机的中心(因此屏幕)。您应该检查场景的后退方法。它将使您的精灵居中,并在您的相机移动时移动它
Sprite background = new Sprite(0,0, CAMERA_WIDTH, CAMERA_HEIGHT, backgroundTextureRegion);
scene.setBackground(new SpriteBackground(background));
您应该检查场景的“收进背景”方法。它将使您的精灵居中,并在您的相机移动时移动它
Sprite background = new Sprite(0,0, CAMERA_WIDTH, CAMERA_HEIGHT, backgroundTextureRegion);
scene.setBackground(new SpriteBackground(background));
什么是雪碧?它的参数是什么?我的问题是Sprite-Sprite=new-Sprite(int,int-texturereregion);我只需要X和Y在场景中使用屏幕的高度和宽度将其居中。我的意思是int是什么?顶部和左侧?哦,X是水平的,Y是垂直的。0从X的最左边开始,0从Y的底部开始。什么是精灵?它的参数是什么?我的问题是Sprite-Sprite=new-Sprite(int,int-texturereregion);我只需要X和Y在场景中使用屏幕的高度和宽度将其居中。我的意思是int是什么?顶部和左侧?哦,X是水平的,Y是垂直的。0从X的最左边开始,0从Y的底部开始!你真的帮了大忙!谢谢你!你真的帮了大忙!