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

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

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

Image.setDrawable介绍

[英]Sets a new drawable for the image. The image's pref size is the drawable's min size. If using the image actor's size rather than the pref size, #pack() can be used to size the image to its pref size.
[中]为图像设置新的可绘制图像。图像的pref size是可绘制图像的最小大小。如果使用图像参与者的大小而不是pref大小,则可以使用#pack()将图像大小调整为其pref大小。

代码示例

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

public void setDrawable (Skin skin, String drawableName) {
  setDrawable(skin.getDrawable(drawableName));
}

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

public void setDrawable (Skin skin, String drawableName) {
  setDrawable(skin.getDrawable(drawableName));
}

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

/** Updates the Image with the appropriate Drawable from the style before it is drawn. */
protected void updateImage () {
  Drawable drawable = null;
  if (isDisabled() && style.imageDisabled != null)
    drawable = style.imageDisabled;
  else if (isPressed() && style.imageDown != null)
    drawable = style.imageDown;
  else if (isChecked && style.imageChecked != null)
    drawable = (style.imageCheckedOver != null && isOver()) ? style.imageCheckedOver : style.imageChecked;
  else if (isOver() && style.imageOver != null)
    drawable = style.imageOver;
  else if (style.imageUp != null) //
    drawable = style.imageUp;
  image.setDrawable(drawable);
}

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

/** Updates the Image with the appropriate Drawable from the style before it is drawn. */
protected void updateImage () {
  Drawable drawable = null;
  if (isDisabled() && style.imageDisabled != null)
    drawable = style.imageDisabled;
  else if (isPressed() && style.imageDown != null)
    drawable = style.imageDown;
  else if (isChecked && style.imageChecked != null)
    drawable = (style.imageCheckedOver != null && isOver()) ? style.imageCheckedOver : style.imageChecked;
  else if (isOver() && style.imageOver != null)
    drawable = style.imageOver;
  else if (style.imageUp != null) //
    drawable = style.imageUp;
  image.setDrawable(drawable);
}

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

/** Updates the Image with the appropriate Drawable from the style before it is drawn. */
protected void updateImage () {
  Drawable drawable = null;
  if (isDisabled() && style.imageDisabled != null)
    drawable = style.imageDisabled;
  else if (isPressed() && style.imageDown != null)
    drawable = style.imageDown;
  else if (isChecked && style.imageChecked != null)
    drawable = (style.imageCheckedOver != null && isOver()) ? style.imageCheckedOver : style.imageChecked;
  else if (isOver() && style.imageOver != null)
    drawable = style.imageOver;
  else if (style.imageUp != null) //
    drawable = style.imageUp;
  image.setDrawable(drawable);
}

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

/** Updates the Image with the appropriate Drawable from the style before it is drawn. */
protected void updateImage () {
  Drawable drawable = null;
  if (isDisabled() && style.imageDisabled != null)
    drawable = style.imageDisabled;
  else if (isPressed() && style.imageDown != null)
    drawable = style.imageDown;
  else if (isChecked && style.imageChecked != null)
    drawable = (style.imageCheckedOver != null && isOver()) ? style.imageCheckedOver : style.imageChecked;
  else if (isOver() && style.imageOver != null)
    drawable = style.imageOver;
  else if (style.imageUp != null) //
    drawable = style.imageUp;
  image.setDrawable(drawable);
}

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

public void draw (Batch batch, float parentAlpha) {
  Drawable checkbox = null;
  if (isDisabled()) {
    if (isChecked && style.checkboxOnDisabled != null)
      checkbox = style.checkboxOnDisabled;
    else
      checkbox = style.checkboxOffDisabled;
  }
  if (checkbox == null) {
    boolean over = isOver() && !isDisabled();
    if (isChecked && style.checkboxOn != null)
      checkbox = over && style.checkboxOnOver != null ? style.checkboxOnOver : style.checkboxOn;
    else if (over && style.checkboxOver != null)
      checkbox = style.checkboxOver;
    else
      checkbox = style.checkboxOff;
  }
  image.setDrawable(checkbox);
  super.draw(batch, parentAlpha);
}

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

public void draw (Batch batch, float parentAlpha) {
  Drawable checkbox = null;
  if (isDisabled()) {
    if (isChecked && style.checkboxOnDisabled != null)
      checkbox = style.checkboxOnDisabled;
    else
      checkbox = style.checkboxOffDisabled;
  }
  if (checkbox == null) {
    boolean over = isOver() && !isDisabled();
    if (isChecked && style.checkboxOn != null)
      checkbox = over && style.checkboxOnOver != null ? style.checkboxOnOver : style.checkboxOn;
    else if (over && style.checkboxOver != null)
      checkbox = style.checkboxOver;
    else
      checkbox = style.checkboxOff;
  }
  image.setDrawable(checkbox);
  super.draw(batch, parentAlpha);
}

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

// initialize
Image kidImage = new Image(dummyDrawable);
// instead of Image kidImage = new Image();
..
..
// run time
kidImage.setDrawable(realDrawable);

代码示例来源:origin: bladecoder/bladecoder-adventure-engine

public void setCollapsable(boolean c) {
  collapsable = c;
  if (c) {
    collapseImg.setDrawable(new TextureRegionDrawable(Ctx.assetManager.getIcon("ic_open")));
  } else
    collapseImg.setDrawable(null);
}

代码示例来源:origin: mbrlabs/Mundus

public void setImage(FileHandle fileHandle) {
  if (texture != null) {
    texture.dispose();
  }
  this.fileHandle = fileHandle;
  if (fileHandle != null) {
    texture = new Texture(fileHandle);
    img.setDrawable(new TextureRegionDrawable(new TextureRegion(texture)));
  } else {
    img.setDrawable(PLACEHOLDER_IMG);
  }
}

代码示例来源:origin: crashinvaders/gdx-texture-packer-gui

private void updatePreviewNinePatch() {
  int[] patches = model.readPatchValues();
  NinePatch ninePatch = new NinePatch(model.texture, patches[0], patches[1], patches[2], patches[3]);
  previewImage.setDrawable(new NinePatchDrawable(ninePatch));
}

代码示例来源: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: dingjibang/GDX-RPG

public void setDrawable(Drawable drawable) {
  super.setDrawable(drawable);
  
  if(Game.setting.filter && drawable instanceof TextureRegionDrawable)
    ((TextureRegionDrawable)drawable).getRegion().getTexture().setFilter(TextureFilter.Linear, TextureFilter.Linear);
}

代码示例来源:origin: crashinvaders/gdx-texture-packer-gui

@Override
  public void process(final LmlParser parser, final LmlTag tag, final Image actor, final String rawAttributeData) {
    Skin skin = parser.getData().getDefaultSkin();
    TiledDrawable drawable = skin.getTiledDrawable(parser.parseString(rawAttributeData, actor));
    actor.setDrawable(drawable);
  }
}

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

private void updateActor(final int position, Group group) {
  ListItem item = items.get(position);
  Image logo = group.findActor("logo");
  group.setName(item.getFrame());
  Drawable drawable = drawableCache.get(item.getFrame());
  if (drawable == null) {
    TextureAtlas.AtlasRegion atlasRegion = stageBuilder.getAssets().getTextureAtlas("common.atlas").findRegion(item.getFrame());
    drawable = new TextureRegionDrawable(atlasRegion);
    drawableCache.put(item.getFrame(), drawable);
  }
  logo.setDrawable(drawable);
}

代码示例来源:origin: bladecoder/bladecoder-adventure-engine

private void showBgImage(String r) {
  if (atlas == null || r == null)
    return;
  bgImage.setDrawable(new TextureRegionDrawable(atlas.findRegion(r)));
  infoContainer.prefWidth(250);
  infoContainer.prefHeight(250);
  setInfoWidget(infoContainer);
}

代码示例来源:origin: kotcrab/vis-ui

@Override
public void draw (Batch batch, float parentAlpha) {
  bgImage.setDrawable(getCheckboxBgImage());
  tickImage.setDrawable(getCheckboxTickImage());
  super.draw(batch, parentAlpha);
  if (isDisabled() == false && stateInvalid && style.errorBorder != null) {
    style.errorBorder.draw(batch, getX() + imageStack.getX(), getY() + imageStack.getY(), imageStack.getWidth(), imageStack.getHeight());
  } else if (focusBorderEnabled && drawBorder && style.focusBorder != null) {
    style.focusBorder.draw(batch, getX() + imageStack.getX(), getY() + imageStack.getY(), imageStack.getWidth(), imageStack.getHeight());
  }
}

相关文章