コード例 #1
0
  public void update(float delta) {
    // We draw the elements in order: from top to bottom.
    // so we need to order the array list
    for (SceneLayer layer : layers) layer.update();

    // music delay update
    if (music != null && !music.isPlaying()) {
      boolean initialTime = false;

      if (currentMusicDelay <= initialMusicDelay) initialTime = true;

      currentMusicDelay += delta;

      if (initialTime) {
        if (currentMusicDelay > initialMusicDelay) playMusic();
      } else {
        if (repeatMusicDelay >= 0 && currentMusicDelay > repeatMusicDelay + initialMusicDelay) {
          currentMusicDelay = initialMusicDelay;
          playMusic();
        }
      }
    }

    for (BaseActor a : actors.values()) {
      a.update(delta);
    }

    camera.update(delta);

    if (followActor != null) {
      camera.updatePos(followActor);
    }
  }
コード例 #2
0
  @Override
  public void retrieveAssets() {

    // RETRIEVE BACKGROUND
    if (backgroundAtlas != null && !backgroundAtlas.isEmpty()) {
      background = EngineAssetManager.getInstance().getRegions(backgroundAtlas, backgroundRegionId);

      int width = 0;

      for (int i = 0; i < background.size; i++) {
        width += background.get(i).getRegionWidth();
      }

      int height = background.get(0).getRegionHeight();

      // Sets the scrolling dimensions. It must be done here because
      // the background must be loaded to calculate the bbox
      camera.setScrollingDimensions(width, height);

      // if(followActor != null)
      // camera.updatePos(followActor);
    }

    // RETRIEVE LIGHT MAP
    if (lightMapAtlas != null && !lightMapAtlas.isEmpty()) {
      lightMap = EngineAssetManager.getInstance().getRegions(lightMapAtlas, lightMapRegionId);
    }

    // RETRIEVE ACTORS
    for (BaseActor a : actors.values()) {
      if (a instanceof AssetConsumer) ((AssetConsumer) a).retrieveAssets();
    }

    if (musicFilename != null) {
      music = EngineAssetManager.getInstance().getMusic(musicFilename);
      if (isPlayingSer) { // TODO must be in World???
        if (music != null) {
          music.setPosition(musicPosSer);
          musicPosSer = 0f;
        }

        playMusic();
        isPlayingSer = false;
      }
    }
  }