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

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

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

Pool.obtain介绍

[英]Returns an object from this pool. The object may be new (from #newObject()) or reused (previously #free(Object)).
[中]从该池返回一个对象。对象可能是新的(来自#newObject())或重用的(以前是#free(object))。

代码示例

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

public Node<E> obtain (Node<E> p, Node<E> n, E value, int index) {
    Node<E> newNode = super.obtain();
    newNode.p = p;
    newNode.n = n;
    newNode.value = value;
    newNode.index = index;
    return newNode;
  }
}

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

private void postTouchEvent (AndroidInput input, int type, int x, int y, int pointer, int button, long timeStamp) {
  TouchEvent event = input.usedTouchEvents.obtain();
  event.timeStamp = timeStamp;
  event.pointer = pointer;
  event.x = x;
  event.y = y;
  event.type = type;
  event.button = button;
  input.touchEvents.add(event);
}

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

private void postTouchEvent (AndroidInput input, int type, int x, int y, int scrollAmount, long timeStamp) {
  TouchEvent event = input.usedTouchEvents.obtain();
  event.timeStamp = timeStamp;
  event.x = x;
  event.y = y;
  event.type = type;
  event.scrollAmount = scrollAmount;
  input.touchEvents.add(event);
}

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

/** Reuses a previous freed instance or creates a new instance and set it to reflect the specified native object */
public static btBroadphasePair obtain(long cPtr, boolean own) {
  final btBroadphasePair result = pool.obtain();
  result.reset(cPtr, own);
  return result;
}
/** delete the native object if required and allow the instance to be reused by the obtain method */

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

private Cell obtainCell () {
  Cell cell = cellPool.obtain();
  cell.setLayout(this);
  return cell;
}

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

private Cell obtainCell () {
  Cell cell = cellPool.obtain();
  cell.setLayout(this);
  return cell;
}

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

/** Reuses a previous freed instance or creates a new instance and set it to reflect the specified native object */
public static btBroadphaseProxy obtain(long cPtr, boolean own) {
  final btBroadphaseProxy result = pool.obtain();
  result.reset(cPtr, own);
  return result;
}
/** delete the native object if required and allow the instance to be reused by the obtain method */

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

/** Reuses a previous freed instance or creates a new instance and set it to reflect the specified native object */
public static btBroadphasePair obtain(long cPtr, boolean own) {
  final btBroadphasePair result = pool.obtain();
  result.reset(cPtr, own);
  return result;
}
/** delete the native object if required and allow the instance to be reused by the obtain method */

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

/** Reuses a previous freed instance or creates a new instance and set it to reflect the specified native object */
public static btBroadphaseProxy obtain(long cPtr, boolean own) {
  final btBroadphaseProxy result = pool.obtain();
  result.reset(cPtr, own);
  return result;
}
/** delete the native object if required and allow the instance to be reused by the obtain method */

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

@Override
public T obtain () {
  T result = super.obtain();
  obtained.add(result);
  return result;
}

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

@Override
public void keyTyped (java.awt.event.KeyEvent e) {
  synchronized (this) {
    KeyEvent event = usedKeyEvents.obtain();
    event.keyChar = e.getKeyChar();
    event.keyCode = 0;
    event.type = KeyEvent.KEY_TYPED;
    event.timeStamp = System.nanoTime();
    keyEvents.add(event);
    lwjglAwtCanvas.graphics.requestRendering();
  }
}

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

/** Returns a new or pooled action of the specified type. */
static public <T extends Action> T action (Class<T> type) {
  Pool<T> pool = Pools.get(type);
  T action = pool.obtain();
  action.setPool(pool);
  return action;
}

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

@Override
public void onGamepadDisconnected (int index) {
  GwtController controller = controllerMap.remove(index);
  if (controller != null) {
    synchronized (eventQueue) {
      GwtControllerEvent event = eventPool.obtain();
      event.type = GwtControllerEvent.DISCONNECTED;
      event.controller = controller;
      eventQueue.add(event);
    }
  }
}

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

@Override
public void getRenderables (Array<Renderable> renderables, Pool<Renderable> pool) {
  for (Renderable renderable : this.renderables)
    renderables.add(pool.obtain().set(renderable));
}

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

@Override
public Renderable obtain () {
  Renderable renderable = super.obtain();
  renderable.environment = null;
  renderable.material = null;
  renderable.meshPart.set("", null, 0, 0, 0);
  renderable.shader = null;
  obtained.add(renderable);
  return renderable;
}

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

/** Returns a new or pooled action of the specified type. */
static public <T extends Action> T action (Class<T> type) {
  Pool<T> pool = Pools.get(type);
  T action = pool.obtain();
  action.setPool(pool);
  return action;
}

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

protected void getRenderables (Node node, Array<Renderable> renderables, Pool<Renderable> pool) {
  if (node.parts.size > 0) {
    for (NodePart nodePart : node.parts) {
      if (nodePart.enabled) renderables.add(getRenderable(pool.obtain(), node, nodePart));
    }
  }
  for (Node child : node.getChildren()) {
    getRenderables(child, renderables, pool);
  }
}

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

private void addDebugRect (float x, float y, float w, float h, Color color) {
  if (debugRects == null) debugRects = new Array();
  DebugRect rect = DebugRect.pool.obtain();
  rect.color = color;
  rect.set(x, getHeight() - y - h, w, h);
  debugRects.add(rect);
}

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

protected void getRenderables (Node node, Array<Renderable> renderables, Pool<Renderable> pool) {
  if (node.parts.size > 0) {
    for (NodePart nodePart : node.parts) {
      if (nodePart.enabled) renderables.add(getRenderable(pool.obtain(), node, nodePart));
    }
  }
  for (Node child : node.getChildren()) {
    getRenderables(child, renderables, pool);
  }
}

代码示例来源: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);
}

相关文章