我想叠加两个精灵但是,当我调整我的窗口大小时,精灵会移动......
我的代码:
public void resize(int width, int height) {
// TODO Auto-generated method stub
if ( height < width ){
spriteAbalone.setScale(height/700f);
billeBlanche.setScale(height/700f);
}
else{
spriteAbalone.setScale(width/700f);
billeBlanche.setScale(width/700f);
}
spriteAbalone.setPosition((width-700)/2, (height - 700)/2);
billeBlanche.setPosition((width-400)/2,(height-400)/2);
camera.setToOrtho(false, width, height);
camera.update();
}
@Override
public void show() {
// TODO Auto-generated method stub
float screenW = Gdx.graphics.getWidth();
float screenH = Gdx.graphics.getHeight();
camera = new OrthographicCamera();
camera.setToOrtho(false, screenW, screenH);
batch = new SpriteBatch();
spriteAbalone = new Sprite(new TextureRegion(new Texture(Gdx.files.internal("data/AbaloneCS5.gif")), 0, 0, 704, 704));
spriteAbalone.setSize(700 , 700);
spriteAbalone.setOrigin(704/2,704/2);
billeBlanche = new Sprite(new TextureRegion(new Texture(Gdx.files.internal("data/billeblanche.gif")),0,0,200,200));
billeBlanche.setSize(65, 65);
billeBlanche.setOrigin(704/2,704/2);
}