本文整理汇总了Java中com.badlogic.gdx.utils.Pools类的典型用法代码示例。如果您正苦于以下问题:Java Pools类的具体用法?Java Pools怎么用?Java Pools使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Pools类属于com.badlogic.gdx.utils包,在下文中一共展示了Pools类的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);
}
示例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;
}
示例3: removeGameEntity
import com.badlogic.gdx.utils.Pools; //导入依赖的package包/类
public void removeGameEntity(GameEntity gameEntity){
final Entity entity = gameEntity.entity;
final PhysicsComponent phyC = Mappers.physics.get(entity);
final RenderableComponent renderableC = Mappers.renderable.get(entity);
final LifeBarComponent lifeBarComponent = Mappers.lifeBar.get(entity);
if(renderableC != null){
renderableC.renderable.remove();
}
if(lifeBarComponent != null){
lifeBarComponent.lifeBar.remove();
}
if(phyC != null){
final Body body = phyC.body;
physicsCtrl.destroyBody(body);
}
Pools.free(gameEntity);
}
示例4: drawSelf
import com.badlogic.gdx.utils.Pools; //导入依赖的package包/类
@Override
protected void drawSelf(KrRenderer renderer) {
if (popupMenu.isShowing()) {
renderer.setBrush(((KrComboBoxStyle) getStyle()).pressedBackground);
} else {
renderer.setBrush(((KrComboBoxStyle) getStyle()).background);
}
renderer.fillRect(0, 0, getWidth(), getHeight());
rectangles(0, 0, getWidth(), getHeight()).shrink(getPadding()).value(tmpRect);
Vector2 pTextPosition = KrAlignmentTool.alignRectangles(text.getBounds(), tmpRect, KrAlignment.MIDDLE_LEFT);
renderer.setPen(1, getForeground());
renderer.drawText(text.getString(), pTextPosition);
Pools.free(pTextPosition);
}
示例5: drawSelf
import com.badlogic.gdx.utils.Pools; //导入依赖的package包/类
@Override
protected void drawSelf(KrRenderer renderer) {
Drawable grip = ((KrSplitPanelStyle) KrSplitPanel.this.getStyle()).splitterGrip;
Rectangle gripRectangle = Pools.obtain(Rectangle.class).set(0, 0, grip.getMinWidth(), grip.getMinHeight());
Rectangle geometryRectangle = Pools.obtain(Rectangle.class).set(0, 0, getWidth(), getHeight());
Vector2 gripPosition = alignRectangles(gripRectangle, geometryRectangle, MIDDLE_CENTER);
gripRectangle.setPosition(gripPosition);
renderer.setBrush(grip);
renderer.fillRect(gripRectangle);
Pools.free(getGeometry());
Pools.free(geometryRectangle);
Pools.free(gripRectangle);
}
示例6: drawSelf
import com.badlogic.gdx.utils.Pools; //导入依赖的package包/类
@Override
protected void drawSelf(KrRenderer renderer) {
boolean componentClip = renderer.beginClip(0, 0, getWidth(), getHeight());
renderer.setBrush(getStyle().background);
renderer.fillRect(0, 0, getWidth(), getHeight());
text.getBounds(tmpRect);
Rectangle alignmentReference = rectangles(0.0f, 0.0f, getWidth(), getHeight()).shrink(getPadding()).value();
Vector2 textPosition = KrAlignmentTool.alignRectangles(tmpRect, alignmentReference, getTextAlignment());
renderer.setPen(1, getStyle().foregroundColor);
renderer.setFont(getStyle().font);
renderer.drawText(text.getString(), textPosition);
if (componentClip) {
renderer.endClip();
}
Pools.free(textPosition);
Pools.free(alignmentReference);
}
示例7: getSelectionRect
import com.badlogic.gdx.utils.Pools; //导入依赖的package包/类
@ReturnsPooledObject
private Rectangle getSelectionRect(float textPositionX) {
KrFontMetrics metrics = getDefaultToolkit().fontMetrics();
String text = textDocument.getText();
float selectionStartX = textPositionX + metrics.bounds(getStyle().font, text.substring(0, textDocument.getSelectionBegin()), tmpRect).getWidth();
float selectionEndX = textPositionX + metrics.bounds(getStyle().font, text.substring(0, textDocument.getSelectionEnd()), tmpRect).getWidth();
float selectionWidth = selectionEndX - selectionStartX;
return Pools.obtain(Rectangle.class).set(
selectionStartX,
CARET_TOP_OFFSET,
selectionWidth + 1,
CARET_HEIGHT);
}
示例8: recalculateTextOffset
import com.badlogic.gdx.utils.Pools; //导入依赖的package包/类
private void recalculateTextOffset() {
KrFontMetrics metrics = getDefaultToolkit().fontMetrics();
float textPositionX = getX() + getPadding().left - textOffset;
float caretXPosition = textPositionX + metrics.bounds(getStyle().font, textDocument.getTextBeforeCaret(), tmpRect).width;
float textWidth = metrics.bounds(getStyle().font, textDocument.getText(), tmpRect).width;
Rectangle innerViewport = rectangles(getGeometry(tmpRect)).shrink(getPadding()).value();
if (innerViewport.getWidth() > textWidth) {
textOffset = 0;
return;
}
if (caretXPosition <= innerViewport.x) {
textOffset -= innerViewport.x - caretXPosition;
}
if (caretXPosition >= innerViewport.x + innerViewport.width) {
textOffset += caretXPosition - (innerViewport.x + innerViewport.width) + 1;
}
Pools.free(innerViewport);
}
示例9: layoutInsideCell
import com.badlogic.gdx.utils.Pools; //导入依赖的package包/类
private void layoutInsideCell(KrWidget widget, Rectangle cellBounds) {
Constraint constraint = constraints.get(widget);
Vector2 widgetPreferredSize = widget.getPreferredSize();
int widgetWidth = (widgetPreferredSize.x >= cellBounds.width) ? (int) cellBounds.width : (int) widgetPreferredSize.x;
int widgetHeight = (widgetPreferredSize.y >= cellBounds.height) ? (int) cellBounds.height : (int) widgetPreferredSize.y;
if (constraint.stretchHorizontal) {
widgetWidth = (int) cellBounds.width;
}
if (constraint.stretchVertical) {
widgetHeight = (int) cellBounds.height;
}
Vector2 widgetPosition = KrAlignmentTool.alignRectangles(new Rectangle(0, 0, widgetWidth, widgetHeight), cellBounds, constraint.alignment);
widget.setGeometry((int) widgetPosition.x, (int) widgetPosition.y, widgetWidth, widgetHeight);
Pools.free(widgetPosition);
}
示例10: updateShipProjection
import com.badlogic.gdx.utils.Pools; //导入依赖的package包/类
private void updateShipProjection()
{
if (this.shipProjection != null)
{
Pools.free(this.shipProjection);
}
if (this.level.getGameState() == GameState.PLAY
|| this.level.getGameState() == GameState.COUNTDOWN
|| this.level.getGameState() == GameState.PAUSE
)
{
ArrayList<ProjectionPoint> projectionPoints = PhysicsEngine.gravityProjection(
this.level.getShip().physicsComponent,
this.level.getTrajectorySeconds(),
Constants.Visual.HUD.TrajectoryLine.POINTS_TIME);
this.shipProjection = this.level.processProjection(projectionPoints);
}
else
{
this.shipProjection = null;
}
}
示例11: dispose
import com.badlogic.gdx.utils.Pools; //导入依赖的package包/类
@Override
public void dispose()
{
BackgroundPositionManager.setBackgroundPositionController(new RandomBackgroundPositionController());
GameEntityManager.dispose();
Constants.General.EVENT_BUS.unregister(this);
ScreenManager.removeScreen(this.hudScreen);
this.level.dispose();
AssMan.getGameAssMan().clear();
PhysicsEngine.dispose();
if (this.shipProjection != null)
{
Pools.free(this.shipProjection);
}
}
示例12: applyLevelResult
import com.badlogic.gdx.utils.Pools; //导入依赖的package包/类
Array<RewardResult> applyLevelResult(BaseLevelDescription level, LevelResult result, boolean isWin) {
Array<RewardResult> results = new Array<RewardResult>();
if (isWin) {
boolean isFirstPass = !userData.isPassed(level);
Array<Reward> rewards = isFirstPass ? level.passRewards : level.confirmRewards;
for (Reward reward : rewards) {
results.add(reward.apply(userData));
}
userData.addLevelToPassed(level);
}
for (Die die : result.addedExperience.keys()) {
die.exp += result.addedExperience.get(die, 0);
}
Config.achievements.fire(
EventType.endLevel,
Pools.obtain(EndLevelEvent.class).level(level).win(isWin).result(result)
);
for (Item item : result.viewer.earnedItems.keys()) {
int count = result.viewer.earnedItems.get(item, 0);
userData.incrementItemCount(item, count);
Config.achievements.fire(EventType.earnItem, Pools.obtain(EarnEvent.class).item(item).count(count));
}
userData.setPotions(result.viewer.potions);
save();
return results;
}
示例13: loadInvitations
import com.badlogic.gdx.utils.Pools; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public void loadInvitations(InvitationBuffer invitations) {
ObjectSet<String> tmp = Pools.obtain(ObjectSet.class);
tmp.addAll(invites);
invites.clear();
for (Invitation invitation : invitations) {
invites.add(invitation.getInvitationId());
if (!tmp.contains(invitation.getInvitationId())) {
showInvitation(invitation);
}
}
tmp.clear();
Pools.free(tmp);
Gdx.app.postRunnable(new Runnable() {
@Override public void run() {
invitesDispatcher.setState(invites.size);
}
});
}
示例14: 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);
}
示例15: 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;
}