com.badlogic.gdx.scenes.scene2d.Group.getWidth()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(5.7k)|赞(0)|评价(0)|浏览(83)

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

Group.getWidth介绍

暂无

代码示例

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

public void validate () {
  if (!layoutEnabled) return;
  Group parent = getParent();
  if (fillParent && parent != null) {
    float parentWidth, parentHeight;
    Stage stage = getStage();
    if (stage != null && parent == stage.getRoot()) {
      parentWidth = stage.getWidth();
      parentHeight = stage.getHeight();
    } else {
      parentWidth = parent.getWidth();
      parentHeight = parent.getHeight();
    }
    setSize(parentWidth, parentHeight);
  }
  if (!needsLayout) return;
  needsLayout = false;
  layout();
}

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

public void validate () {
  if (!layoutEnabled) return;
  Group parent = getParent();
  if (fillParent && parent != null) {
    float parentWidth, parentHeight;
    Stage stage = getStage();
    if (stage != null && parent == stage.getRoot()) {
      parentWidth = stage.getWidth();
      parentHeight = stage.getHeight();
    } else {
      parentWidth = parent.getWidth();
      parentHeight = parent.getHeight();
    }
    setSize(parentWidth, parentHeight);
  }
  if (!needsLayout) return;
  needsLayout = false;
  layout();
}

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

parentHeight = stage.getHeight();
} else {
  parentWidth = parent.getWidth();
  parentHeight = parent.getHeight();

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

parentHeight = stage.getHeight();
} else {
  parentWidth = parent.getWidth();
  parentHeight = parent.getHeight();

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

public T show(Group group, float sx, float sy, int aglin) {
  group.addActor(t);
  t.setPosition(group.getWidth() * sx, group.getHeight() * sy, aglin);
  return t;
}

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

private void updateToastsPositions () {
  boolean bottom = (alignment & Align.bottom) != 0;
  boolean left = (alignment & Align.left) != 0;
  float y = bottom ? screenPaddingY : root.getHeight() - screenPaddingY;
  for (Toast toast : toasts) {
    Table table = toast.getMainTable();
    table.setPosition(
        left ? screenPaddingX : root.getWidth() - table.getWidth() - screenPaddingX,
        bottom ? y : y - table.getHeight());
    y += (table.getHeight() + messagePadding) * (bottom ? 1 : -1);
  }
}

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

private void updateToastsPositions () {
  boolean bottom = (alignment & Align.bottom) != 0;
  boolean left = (alignment & Align.left) != 0;
  float y = bottom ? screenPadding : root.getHeight() - screenPadding;
  for (Toast toast : toasts) {
    Table table = toast.getMainTable();
    table.setPosition(
        left ? screenPadding : root.getWidth() - table.getWidth() - screenPadding,
        bottom ? y : y - table.getHeight());
    y += (table.getHeight() + messagePadding) * (bottom ? 1 : -1);
  }
}

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

public void validate () {
  if (!layoutEnabled) return;
  Group parent = getParent();
  if (fillParent && parent != null) {
    float parentWidth, parentHeight;
    Stage stage = getStage();
    if (stage != null && parent == stage.getRoot()) {
      parentWidth = stage.getWidth();
      parentHeight = stage.getHeight();
    } else {
      parentWidth = parent.getWidth();
      parentHeight = parent.getHeight();
    }
    setSize(parentWidth, parentHeight);
  }
  if (!needsLayout) return;
  needsLayout = false;
  layout();
}

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

@Override
  public void draw (Batch batch, float parentAlpha) {
    if (keepWithinParent && getParent() != null) {
      float parentWidth = getParent().getWidth();
      float parentHeight = getParent().getHeight();
      if (getX() < 0) setX(0);
      if (getRight() > parentWidth) setX(parentWidth - getWidth());
      if (getY() < 0) setY(0);
      if (getTop() > parentHeight) setY(parentHeight - getHeight());
    }
    super.draw(batch, parentAlpha);
  }
}

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

/**
 * Target screen resolution(800x480) may be smaller than selected asset resolution(1280x800) for
 * device screen resolution 1280x800. sizeMultiplier in this case will be "1". If there is size
 * information in layout xml file generated for 800x480 target screen resolution, size multiplier value "1" will
 * not work correctly. Position multiplier (1280 / 800 = 1.6) must be used in such cases for providing correct scaling.
 *
 * @param defaultWidth  if width of the actor is not specified in layout file then defaultWidth is multiplied with sizeMultiplier
 * @param defaultHeight if height of the actor is not specified in layout file then defaultHeight is multiplied with sizeMultiplier
 */
protected void normalizeModelSize(BaseModel model, Group parent, float defaultWidth, float defaultHeight) {
  if (parent != null && model.isFillParentWidth()) {
    model.setWidth(parent.getWidth());
  } else {
    float width = model.getWidth();
    model.setWidth(width == 0 ?
        defaultWidth * resolutionHelper.getSizeMultiplier() :
        width * resolutionHelper.getPositionMultiplier());
  }
  if (parent != null && model.isFillParentHeight()) {
    model.setHeight(parent.getHeight());
  } else {
    float height = model.getHeight();
    model.setHeight(height == 0 ?
        defaultHeight * resolutionHelper.getSizeMultiplier() :
        height * resolutionHelper.getPositionMultiplier());
  }
}

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

parentHeight = stage.getHeight();
} else {
  parentWidth = parent.getWidth();
  parentHeight = parent.getHeight();

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

private void updateGroupProperties( ExternalGroupModel model, Group group){
    group.setName( model.getName());
    model.setWidth( group.getWidth());
    model.setHeight( group.getHeight());
    
    // For example .. <FriendsPanel > in top xml and its implementation's root group (FriendsPanel.xml file's) 
    // should both be visible=true in order to set whole group visible, if at least one of them set to false 
    // whole group will be invisible.
    group.setVisible(model.isVisible() && group.isVisible());
    
    Vector2 screenPos;
    if (model.getScreenAlignmentSupport() == null) {
      screenPos = calculateScreenPosition(model.getScreenAlignment(), model);
    } else {
      screenPos = calculateScreenPosition(model.getScreenAlignment(), model.getScreenAlignmentSupport(), model);
    }

    if (screenPos != null) {
      group.setPosition(screenPos.x, screenPos.y);
    } else {
      float positionMultiplier = resolutionHelper.getPositionMultiplier();
      group.setPosition(model.getX() * positionMultiplier, model.getY() * positionMultiplier);
    }

    setScaleProperty(model, group);
  }
}

相关文章

微信公众号

最新文章

更多