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

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

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

Group.setPosition介绍

暂无

代码示例

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

private Group createActorGroup (TextureRegionDrawable bob) {
  Actor main = new DrawableActor(bob);
  main.setPosition(0, 0, Align.center);
  Actor hat = new DrawableActor(bob) {
    @Override
    public void act (float delta) {
      rotateBy(delta * -300);
    }
  };
  hat.setOrigin(Align.center);
  hat.setScale(0.5f);
  hat.setPosition(0, 21, Align.center);
  Group group = new Group() {
    @Override
    public void act (float delta) {
      rotateBy(delta * 120);
      setScale(0.9f + 0.2f * MathUtils.cos(MathUtils.degreesToRadians * getRotation()));
      super.act(delta);
    }
  };
  group.addActor(main);
  group.addActor(hat) ;
  // group.setTransform(false);
  float margin = 35;
  float x = MathUtils.random(margin, stage.getWidth() - margin);
  float y = MathUtils.random(margin, stage.getHeight() - margin);
  group.setPosition(x, y);
  group.setRotation(MathUtils.random(0, 360));
  return group;
}

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

/**
 * Sets the position of the actor's bottom left corner.
 *
 * @param x
 * @param y
 */
@Override
public void setPosition(float x, float y) {
  super.setPosition(x, y);
  setBounds(x, y, getWidth(), getHeight());
}

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

/**
 * set the position use the camera's viewPort . the zero-zero is on the left bottom 
 */
public void setPosition(final float x,final float y){
  super.setPosition(x, y);
  model.body.setTransform(new Vector2(x,y).add(model.drawableOffsetX,model.drawableOffsetY).scl(1/RADIO), model.body.getAngle());
}

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

public Group createSuperRoot() {
  Group SRoot = new Group();
  SRoot.setSize(getFullWidth(), getFullHeight());
  SRoot.setPosition(game.getCenterX(), game.getCenterY(), Align.center);
  return SRoot;
}

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

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

public void resize(float width, float height) {
  changing(width, height);
  getViewport().update(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), true);
  if (isStretching) {//拉伸适配的时候,计算一下iphoneX的安全边距
    calculationCuts();
    calculationAafeArea(1, 1);
    return;
  }
  float bl = getWidth() / getHeight() * Gdx.graphics.getHeight() / Gdx.graphics.getWidth();
  if (bl < 1) {
    cutWidth = (1 - bl) * getWidth() / 2f;
    cutHeight = 0;
    getRoot().setScale(bl, 1);
    getRoot().setPosition(cutWidth, 0);
    cutWidth = cutWidth / getRoot().getScaleX();
    calculationAafeArea(bl, 1);
  } else if (bl >= 1) {
    cutWidth = 0;
    cutHeight = (1 - 1 / bl) * getHeight() / 2f;
    getRoot().setScale(1, 1 / bl);
    getRoot().setPosition(0, cutHeight);
    cutHeight = cutHeight / getRoot().getScaleY();
    calculationAafeArea(1, bl);
  }
  calculationCuts();
}

相关文章

微信公众号

最新文章

更多