1

私人相机 mCamera;私有场景 mMainScene;

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);

}

我的精灵看起来像是被切成了两半。有人可以解释为什么吗?背景颜色仍然是黑色,应该是白色的。

4

1 回答 1

0

您必须在 onCreateScene() 方法中返回场景。你说你的精灵看起来像是被切成了两半,可能是你的图像尺寸比你的位图纹理图大。如果是这样,请增加您的 textureAtlas 大小。

于 2013-09-10T08:47:42.360 回答