Exemplo n.º 1
1
  /**
   * Create a new sound on request to load
   *
   * @param ref The location of the sound to load
   * @param type The type of sound to load
   * @param in The input stream to load from
   */
  public DeferredSound(String ref, InputStream in, int type) {
    this.ref = ref;
    this.type = type;

    if (ref.equals(in.toString()))
      this.in = in; // nasty hack to detect when we're loading from a stream

    LoadingList.get().add(this);
  }
Exemplo n.º 2
0
  /**
   * Create a new deferred texture
   *
   * @param in The input stream from which to read the texture
   * @param resourceName The name to give the resource
   * @param flipped True if the image should be flipped
   * @param filter The filter to apply
   * @param trans The colour to defined as transparent
   */
  public DeferredTexture(
      InputStream in, String resourceName, boolean flipped, int filter, int[] trans) {
    this.in = in;
    this.resourceName = resourceName;
    this.flipped = flipped;
    this.filter = filter;
    this.trans = trans;

    LoadingList.get().add(this);
  }
Exemplo n.º 3
0
 /** Check if the target has been obtained already */
 private void checkTarget() {
   if (target == null) {
     try {
       load();
       LoadingList.get().remove(this);
       return;
     } catch (IOException e) {
       throw new RuntimeException(
           "Attempt to use deferred texture before loading and resource not found: "
               + resourceName);
     }
   }
 }
Exemplo n.º 4
0
  @Override
  public void init(GameContainer gc, StateBasedGame sbg) throws SlickException {

    {
      /* Deferred loading of images for better performances */
      LoadingList loading = LoadingList.get();

      loading.add(
          new DeferredFile("res/menu_graphics/new/menu_screen.png") {
            public void loadFile(String filename) throws SlickException {
              menuBackground = new Image(filename);
            }
          });

      loading.add(
          new DeferredFile("res/menu_graphics/new/menu_button.png") {
            public void loadFile(String filename) throws SlickException {
              menuButton = new Image(filename);
            }
          });

      loading.add(
          new DeferredFile("res/menu_graphics/new/menu_hover.png") {
            public void loadFile(String filename) throws SlickException {
              menuHover = new Image(filename);
            }
          });
    }

    /* Credits text */
    credits =
        new String[][] {
          {
            "Music Assets",
            "\"Beachfront Celebration\" Kevin MacLeod (incompetech.com)",
            "Licensed under Creative Commons: By Attribution 3.0",
            "http://creativecommons.org/licenses/by/3.0/"
          },
          {
            "Images",
            "Loading screen plane created by Sallee Design",
            "http://salleedesign.com/resources/plane-psd/"
          },
          {
            "Font",
            "A love of thunder",
            "Downloaded from DaFont",
            "http://www.dafont.com/a-love-of-thunder.font"
          }
        };
  }