public void onLoadResources()
{
// 想象一下mBitmapTextureAtlas是一张大画布,我们在上边画画,画了四张图片,每张是一个TextureRegion
// 由于四个图片的大小为:
// snapdragon_tiled.png : 400 X 180
// bana_tiled.png : 132 X 70
// face_box_tiled.png : 64 X 32
// helicopter_tiled.png : 96 X 84
// 故总共为 (400 + 132 + 64 + 96) X (180,70, 32, 84中的较大者) = 692 X 180
// 因为长和宽必须为2的幂次,所以我们取1024 X 256
this.mBitmapTextureAtlas = new BitmapTextureAtlas(1024, 256, TextureOptions.BILINEAR);
// 设置png的起始路径,我们把所有的图片都放到了assets/gfx下边
BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/");
// 分别取四个动画的区域
// 解释一下创建mSnapdragonTextureRegion时的参数0,0,4,3,
// 其中的0,0代表该区域在mBitmapTextureAtlas中的起始位置
// 我们需要设置该位置,使四个TextureRegion不重叠
// 同样,想象一下mBitmapTextureAtlas是一张大画布,我们在上边画画,画了四张图片,每张是一个TextureRegion
// 下边解释4,3
// 4代表列数,3代表行数
// 观察一下图片就可以看见,snapdragon_tiled.png这幅图片是分了3行4列的
this.mSnapdragonTextureRegion =
BitmapTextureAtlasTextureRegionFactory.createTiledFromAsset(
this.mBitmapTextureAtlas,
this,
"snapdragon_tiled.png",
0, 0, 4, 3);
this.mHelicopterTextureRegion =
BitmapTextureAtlasTextureRegionFactory.createTiledFromAsset(
this.mBitmapTextureAtlas,
this,
"helicopter_tiled.png",
400, 0, 2, 2);
this.mBananaTextureRegion =
BitmapTextureAtlasTextureRegionFactory.createTiledFromAsset(
this.mBitmapTextureAtlas,
this,
"banana_tiled.png",
496, 0, 4, 2);
this.mFaceTextureRegion =
BitmapTextureAtlasTextureRegionFactory.createTiledFromAsset(
this.mBitmapTextureAtlas,
this,
"face_box_tiled.png",
628, 0, 2, 1);
this.mEngine.getTextureManager().loadTexture(this.mBitmapTextureAtlas);
}