其他分享
首页 > 其他分享> > android-如何使图片显示在屏幕上,几秒钟后删除iteself?

android-如何使图片显示在屏幕上,几秒钟后删除iteself?

作者:互联网

如何在屏幕上显示图片,几秒钟后删除iteself?
就像游戏开始时的教程一样,我知道计时器处理程序是我应该考虑的,但是如何做到呢?

解决方法:

TimerHandler是一个简单的选择.

final Sprite picture = ...
....
TimerHandler removeHandler = new TimerHandler(secondsToRemove, new ITimerCallback() {
    @Override
    public void onTimePassed(final TimerHandler pHandler) {
        picture.unregisterUpdateHandler(pHandler);
        picture.setVisible(false);
        //Or:
        scene.detachChild(picture);
        //You should use the second option, as making the picture invisible does not detach it from your game.
    }
});
picture.registerUpdateHandler(removeHandler);

标签:andengine,timer,android
来源: https://codeday.me/bug/20191101/1986645.html