Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ButtonSprite Shinning when I put two ITextureRegion #254

Open
brunogabriel opened this issue Apr 24, 2014 · 0 comments
Open

ButtonSprite Shinning when I put two ITextureRegion #254

brunogabriel opened this issue Apr 24, 2014 · 0 comments

Comments

@brunogabriel
Copy link

Hello, I'm trying to use 2 ITextureRegion's in My ButtonSprite, but when I use two, the screen maintain shinning. If I put one ITextureRegion (I tested with two and single works normally), the screen don't shinning.

My code example:

import java.io.IOException;
import java.io.InputStream;

import org.andengine.engine.camera.Camera;
import org.andengine.engine.options.EngineOptions;
import org.andengine.engine.options.ScreenOrientation;
import org.andengine.engine.options.resolutionpolicy.RatioResolutionPolicy;
import org.andengine.entity.scene.Scene;
import org.andengine.entity.sprite.ButtonSprite;
import org.andengine.opengl.texture.ITexture;
import org.andengine.opengl.texture.bitmap.BitmapTexture;
import org.andengine.opengl.texture.region.ITextureRegion;
import org.andengine.opengl.texture.region.TextureRegionFactory;
import org.andengine.ui.activity.SimpleBaseGameActivity;
import org.andengine.util.adt.io.in.IInputStreamOpener;

import android.util.Log;

public class MainActivity extends SimpleBaseGameActivity {

private static int CAMERA_WIDTH = 800;
private static int CAMERA_HEIGHT = 480;
ITextureRegion background1;
ITextureRegion background2;

@Override
public EngineOptions onCreateEngineOptions() {
    final Camera camera = new Camera(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT);
    return new EngineOptions(true, ScreenOrientation.LANDSCAPE_FIXED,
            new RatioResolutionPolicy(CAMERA_WIDTH, CAMERA_HEIGHT), camera);
}

@Override
protected void onCreateResources() {

    try {
        ITexture bg = new BitmapTexture(getTextureManager(),
                new IInputStreamOpener() {
                    @Override
                    public InputStream open() throws IOException {
                        return getAssets().open("gfx/spr/jogo01.png");
                    }
                });

        ITexture bg2 = new BitmapTexture(getTextureManager(),
                new IInputStreamOpener() {
                    @Override
                    public InputStream open() throws IOException {
                        return getAssets().open("gfx/spr/jogo02.png");
                    }
                });
        bg.load();
        bg2.load();
        background1 = TextureRegionFactory.extractFromTexture(bg);
        background2 = TextureRegionFactory.extractFromTexture(bg2);
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}

@Override
protected Scene onCreateScene() {
    final Scene scene = new Scene();
    ButtonSprite buttonSprite = new ButtonSprite(0, 0, background1, background2,
            getVertexBufferObjectManager());
    Log.v("Hello:", "" + buttonSprite.getCurrentTileIndex());
    scene.registerTouchArea(buttonSprite);
    scene.attachChild(buttonSprite);
    buttonSprite.setCurrentTileIndex(0);

    return scene;
}

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant