简体   繁体   中英

Andengine fade in/out and alpha modifiers not working

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?

Did you set the blend function properly? Example:

sprite.setBlendFunction(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);

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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM