コード例 #1
0
ファイル: Map.java プロジェクト: AlanTR/solarus
  /**
   * Returns the first entity under a point of the map, in the specified layer.
   *
   * @param layer the layer
   * @param x x of the point
   * @param y y of the point
   * @return the entity found, or null if there is no entity here
   */
  public MapEntity getEntityAt(Layer layer, int x, int y) {

    MapEntities entities = allEntities[layer.getId()];
    ListIterator<MapEntity> iterator = entities.listIterator(entities.size());
    while (iterator.hasPrevious()) {

      MapEntity entity = iterator.previous();
      if (entity.containsPoint(x, y)) {
        return entity;
      }
    }

    return null;
  }
コード例 #2
0
ファイル: Map.java プロジェクト: AlanTR/solarus
  /**
   * Brings the specified entities to the back, keeping their layer. The order of the specified
   * entities in the map is unchanged.
   *
   * @param entities the entities to move
   */
  public void bringToBack(List<MapEntity> entities) {

    List<MapEntity> sortedEntities = getSortedEntities(entities);

    // bring to back each entity from sortedEntities
    ListIterator<MapEntity> iterator = sortedEntities.listIterator(sortedEntities.size());
    while (iterator.hasPrevious()) {

      MapEntity entity = iterator.previous();
      Layer layer = entity.getLayer();
      allEntities[layer.getId()].remove(entity);
      allEntities[layer.getId()].addFirst(entity);
    }

    setChanged();
    notifyObservers();
  }