I'm running AlphaModifier on a Sprite

mSprite.setBlendFunction(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
mSprite.registerEntityModifier(new AlphaModifier(.5f,1,0.4f));

After that i want to cahnge alpha of mSprite to 1 again.
i tried :

mSprite.setAlpha(1f); 

It won't work

How can i set that alpha to 1 again?

有帮助吗?

解决方案

First of all, if you want to bring the behaviour back from before you modified it, you should probably call

setBlendFunction(IShape.BLENDFUNCTION_SOURCE_DEFAULT, IShape.BLENDFUNCTION_DESTINATION_DEFAULT)

otherwise before each rendering call it will use your parameters. In addition, since the AlphaModifier will be called at each onUpdate() (this means at least one per frame), it will overwrite your new value. You should remove the modifier (or make sure that it is removed once it finishes), and then you can set the transparency you prefer.

其他提示

sorry for the delay.

This is what I've done.

mSprite.setAlpha(0);
mSprite.setBlendFunction(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
mSprite.registerEntityModifier(new AlphaModifier(.5f,0,1));

After Alpha Modifier Finish i set the aplha to 0.
Then again register the blend function.
Then again register alphaModifier which brings alpha back to 1.

It gives a little animation kind of effect too so, I preferred this way.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top