Java 类org.newdawn.slick.loading.DeferredResource 实例源码

项目:monkey-shines-java-port    文件:SlickMonkeyShines.java   
@Override public void update(GameContainer container, StateBasedGame game, int delta) throws SlickException {

    // load three at a time.
    for (int i = 0; i < LoadingList.get().getRemainingResources(); ++i) {
        DeferredResource asset = LoadingList.get().getNext();
        if (asset != null) {
            try {
                asset.load();
            } catch (IOException e) {
                throw new SlickException("Issue asynchronously loading world resources: " + e.getMessage(), e);
            }
        } else {
            break;
        }

        if (i > 2)
            { break; }
    }

    if (LoadingList.get().getRemainingResources() == 0 && timeInSplash > MIN_FRAMES_IN_SPLASH) {
        // Tell next state to actually build the world now that the graphics are in place; remember,
        // certain calculations require the actual graphics, such as determining the number of hazards.

        worldIsReady(game);
        game.enterState(
            Game.ID, 
            new FadeOutTransition(Color.black), 
            new FadeInTransition(Color.black));
    }

    ++timeInSplash;
}