嘗試使用andengine加載一個精靈實體,但精靈的底部和右側被切斷。Andengine GLES2精靈在底部和右側被修剪
代碼:
/*
* Create the bitmap texture atlas for the sprite's texture region
*/
BuildableBitmapTextureAtlas mBitmapTextureAtlas = new BuildableBitmapTextureAtlas(
mEngine.getTextureManager(), 256, 256, TextureOptions.BILINEAR);
/*
* Create the sprite's texture region via the
* BitmapTextureAtlasTextureRegionFactory
*/
mSpriteTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromResource(
mBitmapTextureAtlas, c, getSpriteId());
/* Build the bitmap texture atlas */
try
{
mBitmapTextureAtlas
.build(new BlackPawnTextureAtlasBuilder<IBitmapTextureAtlasSource, BitmapTextureAtlas>(
0, 1, 1));
}
catch (TextureAtlasBuilderException e)
{
e.printStackTrace();
}
/*
* Load the bitmap texture atlas into the device's gpu memory
*/
mBitmapTextureAtlas.load();
mSprite = new Sprite(getInitialX(), getInitialY(), mSpriteTextureRegion,
engine.getVertexBufferObjectManager());
/* Attach the marble to the Scene */
scene.attachChild(mSprite);
真棒,修復它。我想這意味着我必須手動管理DPI/sprite縮放比例吧? –
很高興工作!並回答你關於管理DPI/sprite縮放的問題。答案是肯定的,有點。使用不同的ResolutionPolicy類型,您有一組工具。有很多寫在你的谷歌主題。你想要投入多少工作取決於你的項目。 –