当前位置: 首页>>代码示例>>Java>>正文


Java Pools.obtain方法代码示例

本文整理汇总了Java中com.badlogic.gdx.utils.Pools.obtain方法的典型用法代码示例。如果您正苦于以下问题:Java Pools.obtain方法的具体用法?Java Pools.obtain怎么用?Java Pools.obtain使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.badlogic.gdx.utils.Pools的用法示例。


在下文中一共展示了Pools.obtain方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: drawPlayerNames

import com.badlogic.gdx.utils.Pools; //导入方法依赖的package包/类
void drawPlayerNames(){
GlyphLayout layout = Pools.obtain(GlyphLayout.class);

      Draw.tscl(0.25f/2);
   for(Player player : Vars.control.playerGroup.all()){
      if(!player.isLocal){
       	layout.setText(Core.font, player.name);
		Draw.color(0f, 0f, 0f, 0.3f);
		Draw.rect("blank", player.x, player.y + 8 - layout.height/2, layout.width + 2, layout.height + 2);
		Draw.color();
		Draw.tcolor(NetClient.colorArray[player.id % NetClient.colorArray.length]);
           Draw.text(player.name, player.x, player.y + 8);
           Draw.tcolor();
          }
      }
Pools.free(layout);
      Draw.tscl(Vars.fontscale);
  }
 
开发者ID:Anuken,项目名称:Mindustry,代码行数:19,代码来源:Renderer.java

示例2: fireEventOnActor

import com.badlogic.gdx.utils.Pools; //导入方法依赖的package包/类
protected boolean fireEventOnActor(Actor actor, InputEvent.Type type, int pointer, Actor related) {
    if (actor == null || !isActorFocussable(actor) || !isActorHittable(actor))
        return false;

    InputEvent event = Pools.obtain(InputEvent.class);
    event.setType(type);
    event.setStage(this);
    event.setRelatedActor(related);
    event.setPointer(pointer);
    event.setButton(-1);

    actor.fire(event);

    boolean handled = event.isHandled();
    Pools.free(event);
    return handled;
}
 
开发者ID:MrStahlfelge,项目名称:gdx-controllerutils,代码行数:18,代码来源:ControllerMenuStage.java

示例3: debugRender

import com.badlogic.gdx.utils.Pools; //导入方法依赖的package包/类
/** Draws a polygon, using ray start and end points as vertices */
public void debugRender (PolygonShapeRenderer shapeRenderer) {
	shapeRenderer.setColor(Color.BLUE);
	FloatArray vertices = Pools.obtain(FloatArray.class);
	vertices.clear();
	for (int i = 0; i < rayNum; i++) {
		vertices.addAll(mx[i], my[i]);
	}
	for (int i = rayNum - 1; i > -1; i--) {
		vertices.addAll(startX[i], startY[i]);
	}
	vertices.add(vertices.get(0));
	vertices.add(vertices.get(1));
	shapeRenderer.polyline(vertices.shrink());
	Pools.free(vertices);
}
 
开发者ID:Quexten,项目名称:RavTech,代码行数:17,代码来源:RavChainLight.java

示例4: setValue

import com.badlogic.gdx.utils.Pools; //导入方法依赖的package包/类
/**
 * Sets the progress bar position, rounded to the nearest step size and clamped to the minumum and maximim values.
 * {@link #clamp(float)} can be overidden to allow values outside of the progress bars min/max range.
 *
 * @return false if the value was not changed because the progress bar already had the value or it was canceled by a listener.
 */
public boolean setValue(float value) {
    value = snap(clamp(Math.round(value / stepSize) * stepSize));
    float oldValue = this.value;
    if (value == oldValue) {
        return false;
    }
    float oldVisualValue = getVisualValue();
    this.value = value;
    ChangeEvent changeEvent = Pools.obtain(ChangeEvent.class);
    boolean cancelled = fire(changeEvent);
    if (cancelled) {
        this.value = oldValue;
    } else if (animateDuration > 0) {
        animateFromValue = oldVisualValue;
        animateTime = animateDuration;
    }
    Pools.free(changeEvent);
    return !cancelled;
}
 
开发者ID:varFamily,项目名称:cocos-ui-libgdx,代码行数:26,代码来源:ProgressBar.java

示例5: addAnimation

import com.badlogic.gdx.utils.Pools; //导入方法依赖的package包/类
/** Adds an animation to be played delay seconds after the current or last queued animation.
 * @param delay May be <= 0 to use duration of previous animation minus any mix duration plus the negative delay. */
public TrackEntry addAnimation (int trackIndex, Animation animation, boolean loop, float delay) {
	TrackEntry entry = Pools.obtain(TrackEntry.class);
	entry.animation = animation;
	entry.loop = loop;
	entry.endTime = animation != null ? animation.getDuration() : data.defaultMix;

	TrackEntry last = expandToIndex(trackIndex);
	if (last != null) {
		while (last.next != null)
			last = last.next;
		last.next = entry;
	} else
		tracks.set(trackIndex, entry);

	if (delay <= 0) {
		if (last != null) {
			float mix = animation != null ? data.getMix(last.animation, animation) : data.defaultMix;
			delay += last.endTime - mix;
		} else
			delay = 0;
	}
	entry.delay = delay;

	return entry;
}
 
开发者ID:saltares,项目名称:libgdxjam,代码行数:28,代码来源:AnimationStatePR.java

示例6: setValue

import com.badlogic.gdx.utils.Pools; //导入方法依赖的package包/类
public boolean setValue(float value) {
	value = clamp(Math.round(value / stepSize) * stepSize);
	if (!shiftIgnoresSnap || (!Gdx.input.isKeyPressed(Keys.SHIFT_LEFT) && !Gdx.input.isKeyPressed(Keys.SHIFT_RIGHT))) value = snap(value);
	float oldValue = this.value;
	if (value == oldValue) return false;
	float oldVisualValue = getVisualValue();
	this.value = value;
	ChangeEvent changeEvent = Pools.obtain(ChangeEvent.class);
	boolean cancelled = fire(changeEvent);
	if (cancelled) this.value = oldValue;
	else if (animateDuration > 0) {
		animateFromValue = oldVisualValue;
		animateTime = animateDuration;
	}
	Pools.free(changeEvent);
	return !cancelled;
}
 
开发者ID:Dakror,项目名称:Vloxlands,代码行数:18,代码来源:DProgressBar.java

示例7: expandLandToEast

import com.badlogic.gdx.utils.Pools; //导入方法依赖的package包/类
private void expandLandToEast() {
	gameGrid.events().unregister(DroidTowersGame.getSoundController());
	gameGrid.getGridSize().x += GAME_GRID_EXPAND_LAND_SIZE;
	gameGrid.updateWorldSize(false);

	for (GridObject gridObject : gameGrid.getObjects()) {
		GridObjectBoundsChangeEvent event = Pools.obtain(GridObjectBoundsChangeEvent.class);
		event.setGridObject(gridObject);

		gridObject.setPosition(gridObject.getPosition());

		gridObject.broadcastEvent(event);
		Pools.free(event);
	}

	cameraController.panTo(gameGrid.getWorldSize().x, cameraController.getCamera().position.y, true);
	gameGrid.events().register(DroidTowersGame.getSoundController());
}
 
开发者ID:frigidplanet,项目名称:droidtowers,代码行数:19,代码来源:ExpandLandOverlay.java

示例8: mouseMoved

import com.badlogic.gdx.utils.Pools; //导入方法依赖的package包/类
/** Applies a mouse moved event to the stage and returns true if an actor in the scene {@link Event#handle() handled} the event.
 * This event only occurs on the desktop. */
public boolean mouseMoved (int screenX, int screenY) {
	if (screenX < viewport.getScreenX() || screenX >= viewport.getScreenX() + viewport.getScreenWidth()) return false;
	if (Gdx.graphics.getHeight() - screenY < viewport.getScreenY()
		|| Gdx.graphics.getHeight() - screenY >= viewport.getScreenY() + viewport.getScreenHeight()) return false;

	mouseScreenX = screenX;
	mouseScreenY = screenY;

	screenToStageCoordinates(tempCoords.set(screenX, screenY));

	InputEvent event = Pools.obtain(InputEvent.class);
	event.setStage(this);
	event.setType(Type.mouseMoved);
	event.setStageX(tempCoords.x);
	event.setStageY(tempCoords.y);

	Actor target = hit(tempCoords.x, tempCoords.y, true);
	if (target == null) target = root;

	target.fire(event);
	boolean handled = event.isHandled();
	Pools.free(event);
	return handled;
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:27,代码来源:Stage.java

示例9: setScrollFocus

import com.badlogic.gdx.utils.Pools; //导入方法依赖的package包/类
/** Sets the actor that will receive scroll events.
 * @param actor May be null. */
public void setScrollFocus (Actor actor) {
	if (scrollFocus == actor) return;
	FocusEvent event = Pools.obtain(FocusEvent.class);
	event.setStage(this);
	event.setType(FocusEvent.Type.scroll);
	Actor oldScrollFocus = keyboardFocus;
	if (oldScrollFocus != null) {
		event.setFocused(false);
		event.setRelatedActor(actor);
		oldScrollFocus.fire(event);
	}
	if (!event.isCancelled()) {
		scrollFocus = actor;
		if (actor != null) {
			event.setFocused(true);
			event.setRelatedActor(oldScrollFocus);
			actor.fire(event);
			if (event.isCancelled()) setScrollFocus(oldScrollFocus);
		}
	}
	Pools.free(event);
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:25,代码来源:Stage.java

示例10: fireEnterAndExit

import com.badlogic.gdx.utils.Pools; //导入方法依赖的package包/类
private Actor fireEnterAndExit(Actor paramActor, int paramInt1, int paramInt2, int paramInt3)
{
  screenToStageCoordinates(this.stageCoords.set(paramInt1, paramInt2));
  Actor localActor = hit(this.stageCoords.x, this.stageCoords.y);
  if (localActor == paramActor)
    return paramActor;
  InputEvent localInputEvent = (InputEvent)Pools.obtain(InputEvent.class);
  localInputEvent.setStage(this);
  localInputEvent.setStageX(this.stageCoords.x);
  localInputEvent.setStageY(this.stageCoords.y);
  localInputEvent.setPointer(paramInt3);
  if (paramActor != null)
  {
    localInputEvent.setType(InputEvent.Type.exit);
    localInputEvent.setRelatedActor(localActor);
    paramActor.fire(localInputEvent);
  }
  if (localActor != null)
  {
    localInputEvent.setType(InputEvent.Type.enter);
    localInputEvent.setRelatedActor(paramActor);
    localActor.fire(localInputEvent);
  }
  Pools.free(localInputEvent);
  return localActor;
}
 
开发者ID:isnuryusuf,项目名称:ingress-indonesia-dev,代码行数:27,代码来源:Stage.java

示例11: computeTransformFor

import com.badlogic.gdx.utils.Pools; //导入方法依赖的package包/类
/**
 * For a given actor computes and applies the transformation to keep the
 * same screen transformation in a new group
 * 
 * @param actor
 * @param parent
 */
public static void computeTransformFor(Actor actor, Group parent) {
	Vector2 tmp1 = Pools.obtain(Vector2.class);
	Vector2 tmp2 = Pools.obtain(Vector2.class);
	Vector2 tmp3 = Pools.obtain(Vector2.class);
	Vector2 tmp4 = Pools.obtain(Vector2.class);
	Vector2 tmp5 = Pools.obtain(Vector2.class);

	calculateBounds(actor, tmp4, tmp5);
	Vector2 o = tmp1.set(tmp4.x, tmp4.y);
	Vector2 t = tmp2.set(tmp4.x + tmp5.x, tmp4.y);
	Vector2 n = tmp3.set(tmp4.x, tmp4.y + tmp5.y);
	actor.localToAscendantCoordinates(parent, o);
	actor.localToAscendantCoordinates(parent, t);
	actor.localToAscendantCoordinates(parent, n);
	actor.setRotation(actor.getRotation() + actor.getParent().getRotation());
	applyTransformation(actor, o, t, n);

	Pools.free(tmp1);
	Pools.free(tmp2);
	Pools.free(tmp3);
	Pools.free(tmp4);
	Pools.free(tmp5);
}
 
开发者ID:e-ucm,项目名称:ead,代码行数:31,代码来源:EngineUtils.java

示例12: createNode

import com.badlogic.gdx.utils.Pools; //导入方法依赖的package包/类
private RuntimeNode createNode(Entity entity, Conversation conversation,
		int nodeId) {
	Node node = getNode(conversation, nodeId);
	Class runtimeClass = node == null ? null : nodeClasses.get(node
			.getClass());
	if (runtimeClass == null) {
		if (node != null) {
			Gdx.app.error("NodeSystem", "No node for " + node.getClass()
					+ ". Conversation will end.");
		}
		return null;
	}

	RuntimeNode runtimeNode = (RuntimeNode) Pools.obtain(runtimeClass);
	runtimeNode.setGameLoop(gameLoop);
	runtimeNode.setEntity(entity);
	runtimeNode.setConversation(conversation);
	runtimeNode.setNode(node);

	return runtimeNode;
}
 
开发者ID:e-ucm,项目名称:ead,代码行数:22,代码来源:NodeSystem.java

示例13: touchDown

import com.badlogic.gdx.utils.Pools; //导入方法依赖的package包/类
public boolean touchDown(InputEvent paramInputEvent, float paramFloat1, float paramFloat2, int paramInt1, int paramInt2)
{
  if ((paramInt1 == 0) && (paramInt2 != 0))
    return false;
  this.this$1.stageToLocalCoordinates(Vector2.tmp);
  float f1 = Vector2.tmp.x;
  float f2 = Vector2.tmp.y;
  if ((f1 > 0.0F) && (f1 < this.this$1.getWidth()) && (f2 > 0.0F) && (f2 < this.this$1.getHeight()))
  {
    this.this$1.listSelectedIndex = ((int)((this.this$1.getHeight() - f2) / this.this$1.itemHeight));
    this.this$1.listSelectedIndex = Math.max(0, this.this$1.listSelectedIndex);
    this.this$1.listSelectedIndex = Math.min(-1 + this.this$1.this$0.items.length, this.this$1.listSelectedIndex);
    this.this$1.this$0.selectedIndex = this.this$1.listSelectedIndex;
    if (this.this$1.this$0.items.length > 0)
    {
      ChangeListener.ChangeEvent localChangeEvent = (ChangeListener.ChangeEvent)Pools.obtain(ChangeListener.ChangeEvent.class);
      this.this$1.this$0.fire(localChangeEvent);
      Pools.free(localChangeEvent);
    }
  }
  return true;
}
 
开发者ID:isnuryusuf,项目名称:ingress-indonesia-dev,代码行数:23,代码来源:SelectBox$SelectList$1.java

示例14: move

import com.badlogic.gdx.utils.Pools; //导入方法依赖的package包/类
private void move(EngineEntity chasing, EngineEntity target, float speedX,
		float speedY, boolean fromBorder) {
	/*
	 * Calculate distance vector. It is a vector that has the direction of
	 * distance vector between target and chasing entities, and module
	 * equals to the speed calculated
	 */
	Vector2 distanceVector = Pools.obtain(Vector2.class);
	BoundingAreaComponent targetBoundingArea = getBoundingArea(target);
	BoundingAreaComponent chasingBoundingArea = getBoundingArea(chasing);
	chasingBoundingArea.distanceTo(targetBoundingArea, distanceVector,
			fromBorder);
	float l = distanceVector.len();
	distanceVector.scl(speedX / l, speedY / l);

	// Move
	chasing.getGroup().moveBy(distanceVector.x, distanceVector.y);
	Pools.free(distanceVector);
}
 
开发者ID:e-ucm,项目名称:ead,代码行数:20,代码来源:ChaseEntitySystem.java

示例15: cloneObject

import com.badlogic.gdx.utils.Pools; //导入方法依赖的package包/类
@Override
public Renderable cloneObject() {
    RenderableRegion newRenderable = Pools.obtain(RenderableRegion.class);
    newRenderable.setEntity(this.entity);
    newRenderable.setRegion(this.region);
    newRenderable.setColor(this.getColor());
    return newRenderable;
}
 
开发者ID:unlimitedggames,项目名称:gdxjam-ugg,代码行数:9,代码来源:RenderableRegion.java


注:本文中的com.badlogic.gdx.utils.Pools.obtain方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。