com.badlogic.gdx.utils.Pool.free()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(7.6k)|赞(0)|评价(0)|浏览(125)

本文整理了Java中com.badlogic.gdx.utils.Pool.free()方法的一些代码示例,展示了Pool.free()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Pool.free()方法的具体详情如下:
包路径:com.badlogic.gdx.utils.Pool
类名称:Pool
方法名:free

Pool.free介绍

[英]Puts the specified object in the pool, making it eligible to be returned by #obtain(). If the pool already contains #max free objects, the specified object is reset but not added to the pool.

The pool does not check if an object is already freed, so the same object must not be freed multiple times.
[中]将指定的对象放入池中,使其有资格由#get()返回。如果池中已包含#max free对象,则会重置指定的对象,但不会将其添加到池中。
池不会检查对象是否已被释放,因此不能多次释放同一对象。

代码示例

代码示例来源:origin: libgdx/libgdx

@Override
public void free (T object) {
  obtained.removeValue(object, true);
  super.free(object);
}

代码示例来源:origin: libgdx/libgdx

/** Removes all actors and cells from the table. */
public void clearChildren () {
  Array<Cell> cells = this.cells;
  for (int i = cells.size - 1; i >= 0; i--) {
    Cell cell = cells.get(i);
    Actor actor = cell.actor;
    if (actor != null) actor.remove();
  }
  cellPool.freeAll(cells);
  cells.clear();
  rows = 0;
  columns = 0;
  if (rowDefaults != null) cellPool.free(rowDefaults);
  rowDefaults = null;
  implicitEndRow = false;
  super.clearChildren();
}

代码示例来源:origin: libgdx/libgdx

/** Queue an animation to be applied when the current is finished. If current is continuous it will be synced on next loop. */
protected AnimationDesc queue (final AnimationDesc anim, float transitionTime) {
  if (current == null || current.loopCount == 0)
    animate(anim, transitionTime);
  else {
    if (queued != null) animationPool.free(queued);
    queued = anim;
    queuedTransitionTime = transitionTime;
    if (current.loopCount < 0) current.loopCount = 1;
  }
  return anim;
}

代码示例来源:origin: libgdx/libgdx

/** delete the native object if required and allow the instance to be reused by the obtain method */
public static void free(final btBroadphaseProxy inst) {
  inst.dispose();
  pool.free(inst);
}

代码示例来源:origin: libgdx/libgdx

/** Queue an animation to be applied when the current is finished. If current is continuous it will be synced on next loop. */
protected AnimationDesc queue (final AnimationDesc anim, float transitionTime) {
  if (current == null || current.loopCount == 0)
    animate(anim, transitionTime);
  else {
    if (queued != null) animationPool.free(queued);
    queued = anim;
    queuedTransitionTime = transitionTime;
    if (current.loopCount < 0) current.loopCount = 1;
  }
  return anim;
}

代码示例来源:origin: libgdx/libgdx

/** delete the native object if required and allow the instance to be reused by the obtain method */
public static void free(final btBroadphaseProxy inst) {
  inst.dispose();
  pool.free(inst);
}

代码示例来源:origin: libgdx/libgdx

/** delete the native object if required and allow the instance to be reused by the obtain method */
public static void free(final btBroadphasePair inst) {
  inst.dispose();
  pool.free(inst);
}

代码示例来源:origin: libgdx/libgdx

/** Frees an object from the {@link #get(Class) pool}. */
static public void free (Object object) {
  if (object == null) throw new IllegalArgumentException("Object cannot be null.");
  Pool pool = typePools.get(object.getClass());
  if (pool == null) return; // Ignore freeing an object that was never retained.
  pool.free(object);
}

代码示例来源:origin: libgdx/libgdx

/** delete the native object if required and allow the instance to be reused by the obtain method */
public static void free(final btBroadphasePair inst) {
  inst.dispose();
  pool.free(inst);
}

代码示例来源:origin: libgdx/libgdx

@Override
public void free (T object) {
  obtained.removeValue(object, true);
  super.free(object);
}

代码示例来源:origin: libgdx/libgdx

/** Frees an object from the {@link #get(Class) pool}. */
static public void free (Object object) {
  if (object == null) throw new IllegalArgumentException("Object cannot be null.");
  Pool pool = typePools.get(object.getClass());
  if (pool == null) return; // Ignore freeing an object that was never retained.
  pool.free(object);
}

代码示例来源:origin: libgdx/libgdx

/** Set the active animation, replacing any current animation. */
protected AnimationDesc setAnimation (final AnimationDesc anim) {
  if (current == null)
    current = anim;
  else {
    if (!allowSameAnimation && anim != null && current.animation == anim.animation)
      anim.time = current.time;
    else
      removeAnimation(current.animation);
    animationPool.free(current);
    current = anim;
  }
  justChangedAnimation = true;
  return anim;
}

代码示例来源:origin: libgdx/libgdx

/** Set the active animation, replacing any current animation. */
protected AnimationDesc setAnimation (final AnimationDesc anim) {
  if (current == null)
    current = anim;
  else {
    if (!allowSameAnimation && anim != null && current.animation == anim.animation)
      anim.time = current.time;
    else
      removeAnimation(current.animation);
    animationPool.free(current);
    current = anim;
  }
  justChangedAnimation = true;
  return anim;
}

代码示例来源:origin: libgdx/libgdx

/** Resets this body after fetching it from the {@link World#freeBodies} Pool. */
protected void reset (long addr) {
  this.addr = addr;
  this.userData = null;
  for (int i = 0; i < fixtures.size; i++)
    this.world.freeFixtures.free(fixtures.get(i));
  fixtures.clear();
  this.joints.clear();
}

代码示例来源:origin: libgdx/libgdx

/** Destroy a fixture. This removes the fixture from the broad-phase and destroys all contacts associated with this fixture.
 * This will automatically adjust the mass of the body if the body is dynamic and the fixture has positive density. All
 * fixtures attached to a body are implicitly destroyed when the body is destroyed.
 * @param fixture the fixture to be removed.
 * @warning This function is locked during callbacks. */
public void destroyFixture (Fixture fixture) {
  this.world.destroyFixture(this, fixture);
  fixture.setUserData(null);
  this.world.fixtures.remove(fixture.addr);
  this.fixtures.removeValue(fixture, true);
  this.world.freeFixtures.free(fixture);
}

代码示例来源:origin: libgdx/libgdx

/** End applying multiple animations to the instance and update it to reflect the changes. */
protected void end () {
  if (!applying) throw new GdxRuntimeException("You must call begin() first");
  for (Entry<Node, Transform> entry : transforms.entries()) {
    entry.value.toMatrix4(entry.key.localTransform);
    transformPool.free(entry.value);
  }
  transforms.clear();
  target.calculateTransforms();
  applying = false;
}

代码示例来源:origin: libgdx/libgdx

/** End applying multiple animations to the instance and update it to reflect the changes. */
protected void end () {
  if (!applying) throw new GdxRuntimeException("You must call begin() first");
  for (Entry<Node, Transform> entry : transforms.entries()) {
    entry.value.toMatrix4(entry.key.localTransform);
    transformPool.free(entry.value);
  }
  transforms.clear();
  target.calculateTransforms();
  applying = false;
}

代码示例来源:origin: libgdx/libgdx

/** Indicates that subsequent cells should be added to a new row and returns the cell values that will be used as the defaults
 * for all cells in the new row. */
public Cell row () {
  if (cells.size > 0) {
    if (!implicitEndRow) {
      if (cells.peek().endRow) return rowDefaults; // Row was already ended.
      endRow();
    }
    invalidate();
  }
  implicitEndRow = false;
  if (rowDefaults != null) cellPool.free(rowDefaults);
  rowDefaults = obtainCell();
  rowDefaults.clear();
  return rowDefaults;
}

代码示例来源:origin: libgdx/libgdx

public void renderSkeleton (final Vector3 from, final Node node) {
  final Vector3 pos = vectorPool.obtain();
  node.globalTransform.getTranslation(pos);
  shapeRenderer.setColor(node.isAnimated ? Color.RED : Color.YELLOW);
  shapeRenderer.box(pos.x, pos.y, pos.z, 0.5f, 0.5f, 0.5f);
  shapeRenderer.setColor(Color.WHITE);
  shapeRenderer.line(from.x, from.y, from.z, pos.x, pos.y, pos.z);
  for (Node child : node.getChildren())
    renderSkeleton(pos, child);
  vectorPool.free(pos);
}

代码示例来源:origin: libgdx/libgdx

public void free (PooledEffect effect) {
  super.free(effect);
  
  effect.reset(false); // copy parameters exactly to avoid introducing error
  if (effect.xSizeScale != this.effect.xSizeScale || effect.ySizeScale != this.effect.ySizeScale || effect.motionScale != this.effect.motionScale){
    Array<ParticleEmitter> emitters = effect.getEmitters();
    Array<ParticleEmitter> templateEmitters = this.effect.getEmitters();
    for (int i=0; i<emitters.size; i++){
      ParticleEmitter emitter = emitters.get(i);
      ParticleEmitter templateEmitter = templateEmitters.get(i);
      emitter.matchSize(templateEmitter);
      emitter.matchMotion(templateEmitter);
    }
    effect.xSizeScale = this.effect.xSizeScale;
    effect.ySizeScale = this.effect.ySizeScale;
    effect.motionScale = this.effect.motionScale;
  }
}

相关文章