andengine中,有很多小技巧,下面将为大家介绍一些
一、图片的创建
之前的例子当中,我们在创建图片的时候,都要预先创建一个区域BitmapTextureAtlas,例如之前在创建坦克sprite例子中,我们为坦克sprite创建了一个BitmapTextureAtlas:
BitmapTextureAtlas mBitmapTextureAtlas = new BitmapTextureAtlas( getTextureManager(), 128, 256, TextureOptions.DEFAULT); mSpriteTiledTextureRegion = BitmapTextureAtlasTextureRegionFactory .createTiledFromAsset(mBitmapTextureAtlas, this, "tank.png", 0, 0, 1, 1); mBitmapTextureAtlas.load();
this.mAutoParallaxBackgroundTexture = new BitmapTextureAtlas(1024, 1024, TextureOptions.DEFAULT); this.mParallaxLayerFront = BitmapTextureAtlasTextureRegionFactory .createFromAsset(this.mAutoParallaxBackgroundTexture, this, "gfx/parallax_background_layer_front.png", 0, 0); this.mParallaxLayerBack = BitmapTextureAtlasTextureRegionFactory .createFromAsset(this.mAutoParallaxBackgroundTexture, this, "gfx/parallax_background_layer_back.png", 0, 188); this.mParallaxLayerMid = BitmapTextureAtlasTextureRegionFactory .createFromAsset(this.mAutoParallaxBackgroundTexture, this, "gfx/parallax_background_layer_mid.png", 0, 669);
未完,待续。。。。