我有一张图片,需要实现淡出/淡入效果。就像这样:
public void fadeInAndOut() {
AlphaAction actionFadeOut = new AlphaAction();
actionFadeOut.setAlpha(0f);
actionFadeOut.setDuration(2f);
AlphaAction actionFadeIn = new AlphaAction();
actionFadeIn.setAlpha(1f);
actionFadeIn.setDuration(2f);
this.addAction(Actions.sequence(actionFadeOut, Actions.delay(2f), actionFadeIn));
}
但是调用这个方法时没有任何反应。
我的绘制方法是:
@Override
public void draw(Batch batch, float parentAlpha) {
super.draw(batch, parentAlpha);
batch.draw(objectImage, getX(), getY(), getWidth() * getScaleX(),
getHeight() * getScaleY());
}
如何使图像的 Alpha 值生效?
提前致谢!