com.badlogic.gdx.scenes.scene2d.ui.Image.setPosition()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(8.2k)|赞(0)|评价(0)|浏览(147)

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

Image.setPosition介绍

暂无

代码示例

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

@Override
public void create () {
  stage = new Stage();
  texture = new Texture(Gdx.files.internal("data/badlogic.jpg"), false);
  texture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
  img = new Image(new TextureRegion(texture));
  img.setSize(100, 100);
  img.setOrigin(50, 50);
  img.setPosition(100, 100);
  img2 = new Image(new TextureRegion(texture));
  img2.setSize(100, 100);
  img2.setOrigin(50, 50);
  img2.setPosition(100, 100);
  img3 = new Image(new TextureRegion(texture));
  img3.setSize(100, 100);
  img3.setOrigin(50, 50);
  img3.setPosition(100, 100);
  stage.addActor(img);
  stage.addActor(img2);
  stage.addActor(img3);
  img.addAction(sequence());
  img2.addAction(parallel(sequence(), moveBy(100, 0, 1)));
  img3.addAction(sequence(parallel(moveBy(100, 200, 2)), Actions.run(this)));
}

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

@Override
public void create () {
  stage = new Stage();
  Action complexAction = forever(sequence(parallel(rotateBy(180, 2), scaleTo(1.4f, 1.4f, 2), alpha(0.7f, 2)),
    parallel(rotateBy(180, 2), scaleTo(1.0f, 1.0f, 2), alpha(1.0f, 2))));
  texture = new Texture(Gdx.files.internal("data/badlogic.jpg"), false);
  texture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
  final Image img1 = new Image(new TextureRegion(texture));
  img1.setSize(100, 100);
  img1.setOrigin(50, 50);
  img1.setPosition(50, 50);
  final Image img2 = new Image(new TextureRegion(texture));
  img2.setSize(50, 50);
  img2.setOrigin(50, 50);
  img2.setPosition(150, 150);
  stage.addActor(img1);
  stage.addActor(img2);
  img1.addAction(complexAction);
  // img2.action(complexAction.copy());
}

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

@Override
public void create () {
  stage = new Stage();
  texture = new Texture(Gdx.files.internal("data/badlogic.jpg"), false);
  texture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
  final Image img = new Image(new TextureRegion(texture));
  img.setSize(100, 100);
  img.setOrigin(50, 50);
  img.setPosition(100, 100);
  // img.addAction(forever(sequence(delay(1.0f), new Action() {
  // public boolean act (float delta) {
  // System.out.println(1);
  // img.clearActions();
  // return true;
  // }
  // })));
  img.addAction(Actions.moveBy(100, 0, 2));
  img.addAction(Actions.after(Actions.scaleTo(2, 2, 2)));
  stage.addActor(img);
}

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

rotate.setPosition(64, blend.getY());
scale.setPosition(128, blend.getY());

代码示例来源:origin: dingjibang/GDX-RPG

public void setPosition(float x, float y) {
  super.setPosition((int)x, (int)y);
}

代码示例来源:origin: stackoverflow.com

Image myImage = new Image(myTexture);
myImage.addAction(Actions.parallel(Actions.moveTo(endX, endY, duration), Actions.rotateBy(degrees, duration)));
myImage.setPosition(startX, startY);
myImage.setOrigin(sizeX/2, sizeY/2);
stage.add(myImage);

代码示例来源:origin: oakes/libgdx-examples

boolean movePiece(Image piece, float xChange, float yChange) {
  int pixelCount = countPixels(0, 0, viewWidth, viewHeight);
  piece.setPosition(piece.getX() + xChange, piece.getY() + yChange);
  if (pixelCount != countPixels(0, 0, viewWidth, viewHeight)) {
    piece.setPosition(piece.getX() - xChange, piece.getY() - yChange);
    return false;
  }
  return true;
}

代码示例来源:origin: oakes/libgdx-examples

Image createPiece(int index) {
  Image piece = new Image(shapes[index]);
  piece.setScale(scale);
  piece.setPosition(0, viewHeight - (4 * scale));
  stage.addActor(piece);
  return piece;
}

代码示例来源:origin: oakes/libgdx-examples

public void render(float delta) {
  Gdx.gl.glClearColor(0, 0, 0, 0);
  Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
  world.step(delta, 10, 10);
  paddle.setPosition(paddleBody.getPosition().x*scale, paddleBody.getPosition().y*scale);
  ball.setPosition(ballBody.getPosition().x*scale, ballBody.getPosition().y*scale);
  Iterator iter = blocks.keySet().iterator();
  while (iter.hasNext()) {
    Body b = (Body) iter.next();
    Image i = (Image) blocks.get(b);
    if (i.hasParent() == false) {
      world.destroyBody(b);
      iter.remove();
    }
  }
  stage.act(delta);
  stage.draw();
}

代码示例来源:origin: oakes/libgdx-examples

void moveColumnsDown(int y) {
    ArrayList<Image> bottomColumns = new ArrayList<Image>();
    ArrayList<Image> topColumns = new ArrayList<Image>();

    int x = 0;
    while (x < viewWidth) {
      Image columnBottom = new Image(ScreenUtils.getFrameBufferTexture(x, 0, scale, y - scale));
      columnBottom.setPosition(x, 0);
      bottomColumns.add(columnBottom);

      if (countPixels(x, y, scale, viewHeight - y) > 0) {
        Image columnTop = new Image(ScreenUtils.getFrameBufferTexture(x, y, scale, viewHeight - y));
        columnTop.setPosition(x, y);
        topColumns.add(columnTop);
      }

      x = x + scale;
    }

    stage.getRoot().clearChildren();

    for (Image column : bottomColumns) {
      stage.addActor(column);
    }
    for (Image column : topColumns) {
      stage.addActor(column);
      while (movePiece(column, 0, -scale)) {}
    }
  }
}

代码示例来源:origin: com.lwgame.gdx/lwgame-core

@Override
public void create() {
  texture = new Texture("badlogic.jpg");
  Image image = new Image(texture);
  image.setPosition((stage.getWidth() - image.getWidth()) / 2, (stage.getHeight() - image.getHeight()) / 2);
  stage.addActor(image);
}
@Override

代码示例来源:origin: com.lwgame.gdx/core

@Override
public void create() {
  texture = new Texture("badlogic.jpg");
  Image image = new Image(texture);
  image.setPosition((stage.getWidth() - image.getWidth()) / 2, (stage.getHeight() - image.getHeight()) / 2);
  stage.addActor(image);
}

代码示例来源:origin: peakgames/libgdx-stagebuilder

private void updateBackgroundImagePosition(Image image) {
  Vector2 selectedResolution = assets.findBestResolution();
  Vector2 backGroundSize = resolutionHelper.calculateBackgroundSize(selectedResolution.x, selectedResolution.y);
  image.setWidth(backGroundSize.x);
  image.setHeight(backGroundSize.y);
  Vector2 backGroundPosition = resolutionHelper.calculateBackgroundPosition(image.getWidth(), image.getHeight());
  Vector2 gameAreaPosition = resolutionHelper.getGameAreaPosition();
   /*
    * stage root position is always set to gameAreaPosition.
    * Since the bg image is also inside the root group, bg image position should be updated.
   */
  image.setPosition(backGroundPosition.x - gameAreaPosition.x, backGroundPosition.y - gameAreaPosition.y);
}

代码示例来源:origin: lycying/c2d-engine

image.setSize(tmp.radius * 2, tmp.radius * 2);
image.setOrigin(tmp.radius, tmp.radius);
image.setPosition(b2Body.drawableOffsetX - tmp.radius, b2Body.drawableOffsetY - tmp.radius);
image.setColor(generateColor());
obj.addActor(image);
image.setSize(tmp.width, tmp.height);
image.setOrigin(tmp.width / 2, tmp.height / 2);
image.setPosition(b2Body.drawableOffsetX - tmp.width / 2, b2Body.drawableOffsetY - tmp.height / 2);
image.setColor(generateColor());
obj.addActor(image);

代码示例来源:origin: lycying/c2d-engine

image.setSize(tmp.radius * 2, tmp.radius * 2);
image.setOrigin(tmp.radius, tmp.radius);
image.setPosition(b2Body.drawableOffsetX - tmp.radius, b2Body.drawableOffsetY - tmp.radius);
image.setColor(generateColor());
obj.addActor(image);
image.setSize(tmp.width, tmp.height);
image.setOrigin(tmp.width / 2, tmp.height / 2);
image.setPosition(b2Body.drawableOffsetX - tmp.width / 2, b2Body.drawableOffsetY - tmp.height / 2);
image.setColor(generateColor());
obj.addActor(image);

代码示例来源:origin: yichen0831/Bomberman_libGdx

indicator0.clearActions();
indicator0.addAction(moveToAction);
indicator1.setPosition(indicatorX, newIndicatorY);
indicator0.clearActions();
indicator0.addAction(moveToAction);
indicator1.setPosition(indicatorX, newIndicatorY);

代码示例来源:origin: Var3D/var3dframe

img_bg.setPosition(getWidth() / 2, getHeight() / 2, Align.center);
img_bg.setColor(model.bgColor);

代码示例来源:origin: yichen0831/Bomberman_libGdx

indicator0 = new Image(new TextureRegion(textureAtlas.findRegion("MainMenuLogo"), 0, 0, 40, 26));
indicator0.setSize(80f, 52f);
indicator0.setPosition(indicatorX, indicatorY);
indicator1.setPosition(indicatorX, indicatorY);
indicator1.setVisible(false);
indications.setPosition(640f - indications.getWidth() - 12f, 12f);

代码示例来源:origin: peakgames/libgdx-stagebuilder

this.boundaryHeight = resolutionHelper.getScreenHeight();
setSize(boundaryWidth, boundaryHeight);
backgroundImage.setPosition(boundaryWidth / 2 - this.backgroundImage.getWidth() / 2, boundaryHeight / 2 - this.backgroundImage.getHeight() / 2);
foregroundImage.setPosition(boundaryWidth / 2 - this.foregroundImage.getWidth() / 2, boundaryHeight / 2 - this.foregroundImage.getHeight() / 2);
if(messageLabel != null) {				
  messageLabel.setPosition(boundaryWidth / 2 - halfOfMessageLabelWidth, boundaryHeight / 2 - halfOfMessageLabelHeight);

代码示例来源:origin: 121077313/cocostudio-ui-libgdx

if (tr != null) {
  Image bg = new Image(tr);
  bg.setPosition((size.getWidth() - bg.getWidth()) / 2,
      (size.getHeight() - bg.getHeight()) / 2);

相关文章