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

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

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

Image.setSize介绍

暂无

代码示例

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

/** @param drawable May be null. */
public Image (Drawable drawable, Scaling scaling, int align) {
  setDrawable(drawable);
  this.scaling = scaling;
  this.align = align;
  setSize(getPrefWidth(), getPrefHeight());
}

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

/** @param drawable May be null. */
public Image (Drawable drawable, Scaling scaling, int align) {
  setDrawable(drawable);
  this.scaling = scaling;
  this.align = align;
  setSize(getPrefWidth(), getPrefHeight());
}

代码示例来源: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: langurmonkey/gaiasky

@Override
public void setSize(float width, float height) {
  //setWidth(width);
  //setHeight(height);
  ownwidth = width;
  ownheight = height;
  super.setSize(width, height);
}

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

/** @param drawable May be null. */
public Image (Drawable drawable, Scaling scaling, int align) {
  setDrawable(drawable);
  this.scaling = scaling;
  this.align = align;
  setSize(getPrefWidth(), getPrefHeight());
}

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

public void setBackground(String imgName, float width, float height, int left, int right, int top, int bottom) {
  NinePatch path = game.getNinePatch(imgName, left, right, top, bottom);
  Image bg = new Image(path);
  bg.setSize(width, height);
  setThis(bg);
}

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

public UI<Image> getImage(String name, float width, float height, int left, int right, int top, int bottom) {
  Image image = new Image(getNinePatch(name, left, right, top, bottom));
  image.setSize(width, height);
  return getUI(image);
}

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

public void setBackground(String imgName, float width, float height, int r) {
  NinePatch path = game.getNinePatch(imgName, r);
  Image bg = new Image(path);
  bg.setSize(width, height);
  setThis(bg);
}

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

/**
 * Image
 */
public UI<Image> getImage(float width, float height) {
  Image image = new Image(getPointTexture());
  image.setSize(width, height);
  return getUI(image);
}

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

public UI<Image> getImage(String name, float width, float height, int edgeDistance) {
  Image image = new Image(getNinePatch(name, edgeDistance));
  image.setSize(width, height);
  return getUI(image);
}

代码示例来源:origin: SquidPony/SquidLib

/**
 * Creates a Image Actor that should look like the glyph '^' in this font, but will be rotate-able.
 * @param color a Color to tint the '^' with
 * @return the Actor, with no position set.
 */
public Image makeDirectionMarker(Color color) {
  if (!initialized) {
    throw new IllegalStateException("This factory has not yet been initialized!");
  }
  Image im = new Image(dirMarker);
  im.setColor(scc.filter(color));
  im.setSize(actualCellWidth, actualCellHeight + (distanceField ? 1 : 0)); //  - lineHeight / actualCellHeight //+ lineTweak * 1f
  im.setOrigin(1); //center
  return im;
}

代码示例来源:origin: SquidPony/SquidLib

/**
 * Converts a TextureRegion into an Image, or if the argument s is null, creates an Image of a solid block. Can be
 * used for preparing images for animation effects. Stretches the TextureRegion to match a single cell's dimensions.
 * @param tr a TextureRegion to make into an Actor, which can be null for a solid block.
 * @param color a Color to tint tr with.
 * @return the Actor, with no position set.
 */
public Actor makeActor(TextureRegion tr, Color color) {
  if (!initialized) {
    throw new IllegalStateException("This factory has not yet been initialized!");
  }
  if (tr == null) {
    Image im = new Image(block);
    im.setColor(scc.filter(color));
    im.setSize(width, height);
    // im.setPosition(x - width * 0.5f, y - height * 0.5f, Align.center);
    return im;
  } else {
    Image im = new Image(tr);
    im.setColor(scc.filter(color));
    im.setSize(width, height);
    // im.setPosition(x - width * 0.5f, y - height * 0.5f, Align.center);
    return im;
  }
}

代码示例来源:origin: SquidPony/SquidLib

/**
 * Converts a TextureRegion into an Image, or if the argument s is null, creates an Image of a solid block. Can be
 * used for preparing images for animation effects. Ensures the returned Image has the given width and height.
 * @param tr a TextureRegion to make into an Actor, which can be null for a solid block.
 * @param color a Color to tint tr with.
 * @return the Actor, with no position set.
 */
public Actor makeActor(TextureRegion tr, Color color, float width, float height) {
  if (!initialized) {
    throw new IllegalStateException("This factory has not yet been initialized!");
  }
  if (tr == null) {
    Image im = new Image(block);
    im.setColor(scc.filter(color));
    im.setSize(width, height);
    // im.setPosition(x - width * 0.5f, y - height * 0.5f, Align.center);
    return im;
  } else {
    Image im = new Image(tr);
    im.setColor(scc.filter(color));
    im.setSize(width, height);
    // im.setPosition(x - width * 0.5f, y - height * 0.5f, Align.center);
    return im;
  }
}

代码示例来源:origin: SquidPony/SquidLib

im.setColor(scc.filter(color));
im.setSize(actualCellWidth, actualCellHeight + (distanceField ? 1 : 0)); //  - lineHeight / actualCellHeight //+ lineTweak * 1f
im.setColor(scc.filter(color));
im.setSize(actualCellWidth * s.length(), actualCellHeight + (distanceField ? 1 : 0)); //   - lineHeight / actualCellHeight //+ lineTweak * 1f

代码示例来源:origin: SquidPony/SquidLib

/**
 * Converts a char into a Label, or if the argument c is '\0', creates an Image of a solid block. Can be used
 * for preparing glyphs for animation effects, and is used internally for this purpose.
 * @param c a char to make into an Actor, which can be the character with Unicode value 0 for a solid block.
 * @param color a Color to tint c with.
 * @return the Actor, with no position set.
 */
public Actor makeActor(char c, Color color) {
  if (!initialized) {
    throw new IllegalStateException("This factory has not yet been initialized!");
  }
  if (c == 0) {
    Image im = new Image(block);
    im.setColor(scc.filter(color));
    //im.setSize(width, height - MathUtils.ceil(bmpFont.getDescent() / 2f));
    im.setSize(actualCellWidth, actualCellHeight + (distanceField ? 1 : 0)); //  - lineHeight / actualCellHeight //+ lineTweak * 1f
    // im.setPosition(x - width * 0.5f, y - height * 0.5f, Align.center);
    return im;
  } else {
    mut.setCharAt(0, getOrDefault(c));
    Label lb = new Label(mut, style);
    lb.setSize(width, height - descent); //+ lineTweak * 1f
    lb.setColor(scc.filter(color));
    return lb;
  }
}

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

/**
 * 设置显示文本
 * 
 * @param text
 *            例如:895+
 */
public void setText(String text) {
  this.text = text;
  clearChildren();
  if (text == null) {
    return;
  }
  char[] arr = text.toCharArray();
  for (char c : arr) {
    int index = index(c, chars);
    Image img = null;
    TextureRegion tr = null;
    if (index != -1) {
      tr = trs[index];
    }
    if (tr == null) {
      img = new Image();
      img.setSize(tileWidth, tileHeight);// 没有的字符显示空格
    } else {
      img = new Image(tr);
    }
    add(img);
  }
  setSize(tileWidth * arr.length, tileHeight);
}

代码示例来源:origin: SquidPony/SquidLib

Color.abgr8888ToColor(im.getColor(), encodedColor);
im.setSize(actualCellWidth, actualCellHeight + (distanceField ? 1 : 0)); //  - lineHeight / actualCellHeight //+ lineTweak * 1f

代码示例来源:origin: kbz/SIFTrain

@Override
public void show() {
  float scaleFactor = stage.getHeight() / GlobalConfiguration.BASE_HEIGHT;
  backgroundImage.setSize(stage.getWidth(), stage.getHeight());
  loadingProgress.setSize(stage.getWidth() * 0.7f, stage.getHeight() * 0.07f);
  loadingProgress.setX(stage.getWidth() * 0.15f);
  loadingProgress.setY(stage.getHeight() * 0.1f);
  infoLabel.setX(stage.getWidth() * 0.1f);
  infoLabel.setY(stage.getHeight() * 0.2f);
  infoLabel.setWrap(true);
  infoLabel.setWidth(stage.getWidth() * 0.8f);
  infoLabel.setHeight(stage.getHeight() * 0.7f);
  infoLabel.setFontScale(scaleFactor);
  stage.addActor(backgroundImage);
  stage.addActor(loadingProgress);
  stage.addActor(infoLabel);
}

相关文章