private BitmapTextureAtlas mBitmapTextureAtlas;
private TextureRegion mPlayerTextureRegion;
@Override
public EngineOptions onCreateEngineOptions() {
this.mCamera = new Camera(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT);
return new EngineOptions(true, ScreenOrientation.PORTRAIT_FIXED, new RatioResolutionPolicy(CAMERA_WIDTH, CAMERA_HEIGHT), this.mCamera);
}
@Override
public void onCreateResources(
OnCreateResourcesCallback pOnCreateResourcesCallback)
throws Exception {
mBitmapTextureAtlas = new BitmapTextureAtlas(this.getTextureManager(), 32, 32);
mPlayerTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.mBitmapTextureAtlas, this, "face_box.png", 0, 0);
mBitmapTextureAtlas.load();
}
@Override
public void onCreateScene(OnCreateSceneCallback pOnCreateSceneCallback)
throws Exception {
this.mEngine.registerUpdateHandler(new FPSLogger());
this.mMainScene = new Scene();
this.mMainScene.setBackground(new Background(1, 1, 1));
final int iStartX = (CAMERA_WIDTH - mBitmapTextureAtlas.getWidth()) / 2;
final int iStartY = (CAMERA_HEIGHT - mBitmapTextureAtlas.getHeight()) / 2;
final Sprite oPlayer = new Sprite(iStartX, iStartY, mPlayerTextureRegion, getVertexBufferObjectManager());
this.mMainScene.attachChild(oPlayer);
}
我的精灵看起来像被切成两半。有人可以解释一下原因吗? 背景颜色仍然是黑色,应该是白色。
答案 0 :(得分:0)
您必须在onCreateScene()方法中返回场景。 并且你说你的精灵看起来像是切成两半,可能你的图像大小比你的bitmaptextureAtlas大。如果是这样,请增加textureAtlas大小。