Ejemplo n.º 1
0
  /**
   * 删除指定精灵
   *
   * @param sprite
   * @return
   */
  public synchronized boolean remove(ISprite sprite) {
    if (sprite == null) {
      return false;
    }
    if (sprites == null) {
      return false;
    }
    boolean removed = false;

    for (int i = size; i > 0; i--) {
      if (sprite.equals(sprites[i - 1])) {
        removed = true;
        size--;
        sprites[i - 1] = sprites[size];
        sprites[size] = null;
        if (size == 0) {
          sprites = new Sprite[0];
        } else {
          compressCapacity(2);
        }
        return removed;
      }
    }
    return removed;
  }
Ejemplo n.º 2
0
 /**
  * 删除所有指定类
  *
  * @param clazz
  * @return
  */
 public synchronized void remove(Class<? extends ISprite> clazz) {
   if (clazz == null) {
     return;
   }
   for (int i = size; i > 0; i--) {
     ISprite sprite = (ISprite) sprites[i - 1];
     Class<? extends ISprite> cls = sprite.getClass();
     if (clazz == null || clazz == cls || clazz.isInstance(sprite) || clazz.equals(cls)) {
       size--;
       sprites[i - 1] = sprites[size];
       sprites[size] = null;
       if (size == 0) {
         sprites = new Sprite[0];
       } else {
         compressCapacity(2);
       }
     }
   }
 }