Beispiel #1
0
  public PooledEntity GetPooledEntity(Entity entity, float time) {
    synchronized (m_available) {
      if (!m_available.isEmpty()) {
        PooledEntity ent = m_available.get(0);
        ent.m_data.SetActive(true);
        try {
          ent.m_data.SetTransform((Transform2D) entity.GetTransform().clone());
        } catch (CloneNotSupportedException ex) {
          ex.printStackTrace();
        }
        ent.SetLife(time);

        m_inUse.add(ent);
        m_available.remove(0);
        return ent;
      } else {
        Entity entity_copy = entity.GetCopy();
        entity_copy.SetActive(true);

        PooledEntity ent = new PooledEntity(entity_copy, time);
        m_inUse.add(ent);
        return ent;
      }
    }
  }
Beispiel #2
0
  public void Update(float delta) {
    for (PooledEntity pe : m_inUse) {
      pe.Update(delta);

      if (pe.IsDead()) {
        //                System.out.println("Released " + pe.m_data.GetName());
        Release(pe);
        break;
      }
    }
  }