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


Java Pools类代码示例

本文整理汇总了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);
  }
 
开发者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: 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);
}
 
开发者ID:unlimitedggames,项目名称:gdxjam-ugg,代码行数:18,代码来源:EngineController.java

示例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);
}
 
开发者ID:alexpana,项目名称:kreativity-ui,代码行数:19,代码来源:KrComboBox.java

示例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);
}
 
开发者ID:alexpana,项目名称:kreativity-ui,代码行数:17,代码来源:KrSplitPanel.java

示例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);
}
 
开发者ID:alexpana,项目名称:kreativity-ui,代码行数:22,代码来源:KrLabel.java

示例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);
}
 
开发者ID:alexpana,项目名称:kreativity-ui,代码行数:17,代码来源:KrTextField.java

示例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);
}
 
开发者ID:alexpana,项目名称:kreativity-ui,代码行数:23,代码来源:KrTextField.java

示例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);
}
 
开发者ID:alexpana,项目名称:kreativity-ui,代码行数:21,代码来源:KrGridLayout.java

示例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;
    }
}
 
开发者ID:overengineering,项目名称:space-travels-3,代码行数:25,代码来源:GameScreen.java

示例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);
    }
}
 
开发者ID:overengineering,项目名称:space-travels-3,代码行数:20,代码来源:GameScreen.java

示例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;
}
 
开发者ID:ratrecommends,项目名称:dice-heroes,代码行数:27,代码来源:DiceHeroes.java

示例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);
        }
    });
}
 
开发者ID:ratrecommends,项目名称:dice-heroes,代码行数:20,代码来源:GameServicesMultiplayer.java

示例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);
}
 
开发者ID:Quexten,项目名称:RavTech,代码行数:17,代码来源:RavChainLight.java

示例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;
}
 
开发者ID:varFamily,项目名称:cocos-ui-libgdx,代码行数:26,代码来源:ProgressBar.java


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