Code :
This is how m initializing camera.
I', trying to get resolution of device and based on that i set camera width and height.
public class GameActivity extends SimpleBaseGameActivity {
private SmoothCamera mCamera;
private DisplayMetrics dM;
private int CAMERA_WIDTH, CAMERA_HEIGHT;
private double ScreenWidth,
ScreenHeight,
resolutionRatio;
public EngineOptions onCreateEngineOptions() {
//set Camera
getDeviceResolution();
setCamera();
EngineOptions options = new EngineOptions(true,
ScreenOrientation.LANDSCAPE_FIXED,
new RatioResolutionPolicy((int)this.getCameraWidth(),(int)this.getCameraHeight()),
//new FillResolutionPolicy(),
mCamera);
return options;
}
private void getDeviceResolution() {
dM = new DisplayMetrics();
this.getWindowManager().getDefaultDisplay().getMetrics(dM);
this.ScreenWidth = dM.widthPixels;
this.ScreenHeight = dM.heightPixels;
this.resolutionRatio = this.ScreenWidth/this.ScreenHeight;
resolutionRatio = (double)Math.round(resolutionRatio * 100) / 100;
Log.d("Resolution","ScrennWidth: "+this.ScreenWidth );
Log.d("Resolution","ScrennHeight: "+this.ScreenHeight );
Log.d("Resolution","Resolution Ratio: " + this.resolutionRatio );
}
private void setCamera() {
if(resolutionRatio == 1.66){
this.setCameraHeight(340);
this.setCameraWidth(400);
}else if(resolutionRatio == 2.13){
this.setCameraHeight(480);
this.setCameraWidth(1024);
}else if(resolutionRatio == 1.77){
this.setCameraHeight(720);
this.setCameraWidth(1280);
}else if(resolutionRatio == 1.5){
this.setCameraHeight(320);
this.setCameraWidth(480);
}else if(resolutionRatio == 1.67){
this.setCameraHeight(480);
this.setCameraWidth(800);
}else {
this.setCameraHeight((int) this.ScreenHeight);
this.setCameraWidth((int) this.ScreenWidth);
}
// Create a Camera
this.mCamera = new SmoothCamera(0,0,(int)getCameraWidth(),(int)getCameraHeight(),100,100,1.0f);
mCamera.setZoomFactor(1.0f);
mCamera.setBoundsEnabled(true);
mCamera.setBounds(0, 0, mCamera.getWidth(), mCamera.getHeight());
}
}
The issue is.
I've etried game on device with resolution 480x320;
and when i tried same code on device with resolution 800X480
I Thinks sprites are not getting scaled on higher resolution devices.
As per my knowledge andengine scales camera and sprites natively.
So why sprites are not getting scaled on this situation?
What should i do to scale up sprites based on resolution?
I tried FillResolutionPolicy too. Same thing.
I'm using TexturePackerExtension of andengine adn SpriteSheets.