12

I have a problem with AndEngine GLES2.

I have this code:

Sprite black = new Sprite(0,0, blackRegion, this.getVertexBufferObjectManager());
black.setSize(CAMERA_WIDTH, CAMERA_HEIGHT);

black.registerEntityModifier(new AlphaModifier(2, 0, 255));

mScene.attachChild(black);

So it's not working. Nothing does...

What do I need to do?

Aviram Fireberger
  • 3,910
  • 5
  • 50
  • 69
Jonas Peteraitis
  • 333
  • 4
  • 16

2 Answers2

22

Did you set the blend function properly? Example:

sprite.setBlendFunction(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
JohnEye
  • 6,436
  • 4
  • 41
  • 67
4

I tried the above but it's not working for me as it should. The modifier works but instead of a steady fade out the image fades out a number of times for the mentioned duration. Any ideas?

Well ultimately i figured out what i was doing wrong. Here's it...

        anySprite.setBlendFunction(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
    IEntityModifier iem = new AlphaModifier(seconds, 0, 255); //for some unknown reason i was passing invalid values and hence it didn't work then :)
    iem.setRemoveWhenFinished(true);
    anySprite.registerEntityModifier(iem);
Mob
  • 129
  • 1
  • 1
  • 6