Andengine 实时壁纸背景图像大于屏幕大小和引擎

Andengine 实时壁纸背景图像大于屏幕大小和引擎,andengine,scale,live-wallpaper,Andengine,Scale,Live Wallpaper,我想对所有屏幕使用一个图像,但如果我加载的图像大于屏幕大小,它将不可见。图像大小为1280x720,屏幕大小为960x540。我能做什么 代码: 下一步: }最好将其缩放以支持所有屏幕: int spriteWidth = 1280; int spriteHeight = 720; int spriteScaleX = spriteWidth/screenWidth; int spriteScaleY = spriteHeight/screenHeight; 将此因子作为背景精灵的比例。它将支

我想对所有屏幕使用一个图像,但如果我加载的图像大于屏幕大小,它将不可见。图像大小为1280x720,屏幕大小为960x540。我能做什么

代码:

下一步:


}

最好将其缩放以支持所有屏幕:

int spriteWidth = 1280;
int spriteHeight = 720;
int spriteScaleX = spriteWidth/screenWidth;
int spriteScaleY = spriteHeight/screenHeight;

将此因子作为背景精灵的比例。它将支持所有设备。

您需要一个保持相机宽度和高度比例的图像,不需要使用大分辨率图像,OpenGL可以保持图像质量

public void onCreateResources(OnCreateResourcesCallback  createResourcesCallback) throws Exception {        
    final BuildableBitmapTextureAtlas bitmapTextureAtlas = new BuildableBitmapTextureAtlas(
            mEngine.getTextureManager(), CAMERA_WIDTH, CAMERA_HEIGHT,
            TextureOptions.BILINEAR); 
            mTextureRegion = BitmapTextureAtlasTextureRegionFactory
            .createFromAsset(bitmapTextureAtlas, this, "gfx/h720x1280a.png");
int spriteWidth = 1280;
int spriteHeight = 720;
int spriteScaleX = spriteWidth/screenWidth;
int spriteScaleY = spriteHeight/screenHeight;