ButtonSprite Shinning when I put two ITextureRegion
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;
}
}