示例#1
0
  /**
   * Get the layer referenced by the supplied layer ID.
   *
   * @param layerID the id of the layer to retrieve.
   * @return the requested layer, or null if requested layer does not exist.
   */
  public Layer getLayer(String layerID) {
    for (Layer layer : layers) {
      if (layer.getLayerID().equals(layerID)) {
        return layer;
      }
    }

    return null;
  }
示例#2
0
  /**
   * Add a component to the layer referred by the supplied ID parameter. Ideally a single component
   * should only be associated with a single layer.
   *
   * @param layerID the ID of the layer to add the component to.
   * @param entity the component to add to the supplied layer.
   */
  public void addToLayer(String layerID, GameEntity entity) {
    Layer layer = getLayer(layerID);

    if (layer == null) {
      layer = new Layer(layerID, layers.size());
      layers.add(layer);
    }

    layer.addEntity(entity);
  }
示例#3
0
  /**
   * Render all components on a layer by layer basis.
   *
   * @param delta the time delta since the last render operation.
   */
  public void render(Camera camera, float delta) {
    spriteBatch.setProjectionMatrix(camera.combined);
    Gdx.gl.glClearColor(1f, 1f, 1.0f, 1.0f);
    Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);

    for (Layer layer : layers) {
      layer.sortLayers();
      spriteBatch.begin();
      for (GameEntity entity : layer.getEntities()) {
        entity.render(spriteBatch, delta);
      }
      spriteBatch.end();
    }
  }