org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlas Java Examples

The following examples show how to use org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlas. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RepeatingSpriteBackground.java    From 30-android-libraries-in-30-days with Apache License 2.0 6 votes vote down vote up
private Sprite loadSprite(final float pCameraWidth, final float pCameraHeight, final TextureManager pTextureManager, final IBitmapTextureAtlasSource pBitmapTextureAtlasSource, final VertexBufferObjectManager pVertexBufferObjectManager) throws IllegalArgumentException {
	this.mBitmapTextureAtlas = new BitmapTextureAtlas(pTextureManager, pBitmapTextureAtlasSource.getTextureWidth(), pBitmapTextureAtlasSource.getTextureHeight(), BitmapTextureFormat.RGBA_8888, TextureOptions.REPEATING_NEAREST);
	final ITextureRegion textureRegion = BitmapTextureAtlasTextureRegionFactory.createFromSource(this.mBitmapTextureAtlas, pBitmapTextureAtlasSource, 0, 0);

	final int width = Math.round(pCameraWidth / this.mScale);
	final int height = Math.round(pCameraHeight / this.mScale);

	textureRegion.setTextureWidth(width);
	textureRegion.setTextureHeight(height);

	this.mBitmapTextureAtlas.load();

	final Sprite sprite = new Sprite(0, 0, width, height, textureRegion, pVertexBufferObjectManager);
	sprite.setScaleCenter(0, 0);
	sprite.setScale(this.mScale);
	return sprite;
}
 
Example #2
Source File: PipePair.java    From OpenFlappyBird with Do What The F*ck You Want To Public License 6 votes vote down vote up
public static void onCreateResources(SimpleBaseGameActivity activity){

		// upper pipe		
		BitmapTextureAtlas upperPipeTextureAtlas = new BitmapTextureAtlas(activity.getTextureManager(), 130, 60, TextureOptions.BILINEAR);
		mUpperPipeTexture = BitmapTextureAtlasTextureRegionFactory.createFromAsset(upperPipeTextureAtlas, activity, "pipeupper.png", 0, 0);
		upperPipeTextureAtlas.load();

		// upper pipe section	
		BitmapTextureAtlas upperPipeSectionTextureAtlas = new BitmapTextureAtlas(activity.getTextureManager(), 120, 1, TextureOptions.BILINEAR);
		mUpperPipeSectionTexture = BitmapTextureAtlasTextureRegionFactory.createFromAsset(upperPipeSectionTextureAtlas, activity, "pipesectionupper.png", 0, 0);
		upperPipeSectionTextureAtlas.load();


		// lower pipe		
		BitmapTextureAtlas lowerPipeTextureAtlas = new BitmapTextureAtlas(activity.getTextureManager(), 130, 60, TextureOptions.BILINEAR);
		mLowerPipeTexture = BitmapTextureAtlasTextureRegionFactory.createFromAsset(lowerPipeTextureAtlas, activity, "pipelower.png", 0, 0);
		lowerPipeTextureAtlas.load();

		// lower pipe section	
		BitmapTextureAtlas lowerPipeSectionTextureAtlas = new BitmapTextureAtlas(activity.getTextureManager(), 120, 1, TextureOptions.BILINEAR);
		mLowerPipeSectionTexture = BitmapTextureAtlasTextureRegionFactory.createFromAsset(lowerPipeSectionTextureAtlas, activity, "pipesectionlower.png", 0, 0);
		lowerPipeSectionTextureAtlas.load();
	}
 
Example #3
Source File: WorldController.java    From tilt-game-android with MIT License 5 votes vote down vote up
private void createBackground(final Bitmap background, @Nullable final String backgroundUrl) {
    if (background == null) return;

    BitmapTextureAtlas bitmapTextureAtlas = new BitmapTextureAtlas(_engine.getTextureManager(), _width, _height, TextureOptions.BILINEAR);
    IBitmapTextureAtlasSource baseTextureSource = new EmptyBitmapTextureAtlasSource(_width, _height);

    final IBitmapTextureAtlasSource bitmapTextureAtlasSource = new BaseBitmapTextureAtlasSourceDecorator(baseTextureSource) {
        @Override
        protected void onDecorateBitmap(Canvas pCanvas) throws Exception {
            if (backgroundUrl != null) {
                Bitmap template = BitmapFactory.decodeStream(GoogleFlipGameApplication.sContext.getAssets().open(backgroundUrl));
                pCanvas.drawBitmap(template, 0, 0, mPaint);
            }

            pCanvas.drawColor(_backgroundColor);
            pCanvas.drawBitmap(background, 0, 0, mPaint);
        }

        @Override
        public BaseBitmapTextureAtlasSourceDecorator deepCopy() {
            throw new IModifier.DeepCopyNotSupportedException();
        }
    };

    ITextureRegion mDecoratedBalloonTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromSource(bitmapTextureAtlas, bitmapTextureAtlasSource,
            0, 0);
    bitmapTextureAtlas.load();

    Sprite sprite = new Sprite(0, 0, mDecoratedBalloonTextureRegion, _engine.getVertexBufferObjectManager());
    sprite.setOffsetCenter(0, 0);
    sprite.setWidth(_width);
    sprite.setHeight(_height);
    _background = new SpriteBackground(sprite);
    _engine.getScene().setBackground(_background);
}
 
Example #4
Source File: AndEngineActivity.java    From 30-android-libraries-in-30-days with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreateResources() throws IOException {
    mTexture = new AssetBitmapTexture(getTextureManager(), getAssets(), "player.png");
    mTextureRegion = TextureRegionFactory.extractFromTexture(mTexture);
    mTexture.load();

    mBitmapTextureAtlas = new BitmapTextureAtlas(getTextureManager(), 100, 100, TextureOptions.BILINEAR);
    mTiledTextureRegion = BitmapTextureAtlasTextureRegionFactory
            .createTiledFromAsset(mBitmapTextureAtlas, getAssets(), "npc-oldman1.png", 0, 0, 4, 1);

    mBitmapTextureAtlas.load();
}
 
Example #5
Source File: ResourceLoader.java    From sopa with Apache License 2.0 5 votes vote down vote up
IFont getFont(final String name, float size, int color, float strokeWidth, int strokeColor) {

        FontFactory.setAssetBasePath("fonts/");

        final ITexture mainFontTexture = new BitmapTextureAtlas(textureManager, 1024, 1024, TextureOptions.BILINEAR);
        IFont font = FontFactory.createStrokeFromAsset(fontManager, mainFontTexture, assetManager, name, size, true,
                color, strokeWidth, strokeColor);
        font.load();

        return font;
    }
 
Example #6
Source File: RepeatingSpriteBackground.java    From 30-android-libraries-in-30-days with Apache License 2.0 4 votes vote down vote up
public BitmapTextureAtlas getBitmapTextureAtlas() {
	return this.mBitmapTextureAtlas;
}
 
Example #7
Source File: FontFactory.java    From 30-android-libraries-in-30-days with Apache License 2.0 4 votes vote down vote up
public static Font create(final FontManager pFontManager, final TextureManager pTextureManager, final int pTextureWidth, final int pTextureHeight, final BitmapTextureFormat pBitmapTextureFormat, final TextureOptions pTextureOptions, final Typeface pTypeface, final float pSize, final boolean pAntiAlias, final int pColor) {
	return FontFactory.create(pFontManager, new BitmapTextureAtlas(pTextureManager, pTextureWidth, pTextureHeight, pBitmapTextureFormat, pTextureOptions), pTypeface, pSize, pAntiAlias, pColor);
}
 
Example #8
Source File: FontFactory.java    From 30-android-libraries-in-30-days with Apache License 2.0 4 votes vote down vote up
public static Font createFromAsset(final FontManager pFontManager, final TextureManager pTextureManager, final int pTextureWidth, final int pTextureHeight, final BitmapTextureFormat pBitmapTextureFormat, final TextureOptions pTextureOptions, final AssetManager pAssetManager, final String pAssetPath, final float pSize, final boolean pAntiAlias, final int pColor) {
	return new Font(pFontManager, new BitmapTextureAtlas(pTextureManager, pTextureWidth, pTextureHeight, pBitmapTextureFormat, pTextureOptions), Typeface.createFromAsset(pAssetManager, FontFactory.sAssetBasePath + pAssetPath), pSize, pAntiAlias, pColor);
}