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

x33g5p2x  于2022-01-16 转载在 其他  
字(3.9k)|赞(0)|评价(0)|浏览(115)

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

Actor.setOrigin介绍

[英]Sets the origin position which is relative to the actor's bottom left corner.
[中]设置相对于演员左下角的原点位置。

代码示例

代码示例来源: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: peakgames/libgdx-stagebuilder

actor.setOrigin(actor.getWidth() / 2, actor.getHeight() / 2);
actor.setRotation(model.getRotation());

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

shapeActor.setOrigin(50, 75);
shapeActor.debug();
sprites.add(shapeActor);

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

@Override
  public void run() {
    actor.setOrigin(origin);
  }
})));

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

public UI<T> setOrigin(int align) {
  t.setOrigin(align);
  return this;
}

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

public TypedGdxQuery<T> origin (int alignment){
  t.setOrigin(alignment);
  return this;
}

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

public TypedGdxQuery<T> origin (int x, int y){
  t.setOrigin(x, y);
  return this;
}

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

public UI<T> setOrigin(float originX, float originY) {
  t.setOrigin(originX, originY);
  return this;
}

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

actor.setOrigin(50, 50);
stage.addActor(actor);
actor.addListener(new InputListener() {

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

public GdxQuery origin (int x, int y){
  for(Actor actor:list())
    actor.setOrigin(x, y);
  return this;
}

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

public GdxQuery origin (int alignment){
  for(Actor actor:list())
    actor.setOrigin(alignment);
  return this;
}

代码示例来源:origin: moribitotech/MTX

private static void setOrigin(Actor actor, Origin origin) {
  switch (origin) {
  case CENTER:
    actor.setOrigin(actor.getWidth() / 2.0f, actor.getHeight() / 2.0f);
    break;
  case TOP_LEFT:
    actor.setOrigin(0.0f, actor.getHeight());
    break;
  case TOP_RIGHT:
    actor.setOrigin(actor.getWidth(), actor.getHeight());
    break;
  case BOTTOM_LEFT:
    actor.setOrigin(0.0f, 0.0f);
    break;
  case BOTTOM_RIGHT:
    actor.setOrigin(actor.getWidth(), 0.0f);
    break;
  case LEFT_CENTER:
    actor.setOrigin(0.0f, actor.getHeight() / 2.0f);
    break;
  case TOP_CENTER:
    actor.setOrigin(actor.getWidth() / 2.0f, actor.getHeight());
    break;
  case BOTTOM_CENTER:
    actor.setOrigin(actor.getWidth() / 2.0f, 0.0f);
    break;
  case RIGHT_CENTER:
    actor.setOrigin(actor.getWidth(), actor.getHeight() / 2.0f);
    break;
  default:

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

public TypedGdxQuery<T> center(boolean setPosition) {
  t.setOrigin(Align.center);
  if(t instanceof Image)
    ((Image)t).setAlign(Align.center);
  if(t instanceof Label)
    ((Label) t).setAlignment(Align.center);
  if(setPosition) {
    t.setX(t.getX() - t.getWidth() / 2);
    t.setY(t.getY() - t.getHeight() / 2);
  }
  return this;
}

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

public GdxQuery center(boolean setPosition) {
  for(Actor actor : list()){
    actor.setOrigin(Align.center);
    if(actor instanceof Image)
      ((Image)actor).setAlign(Align.center);
    if(actor instanceof Label)
      ((Label) actor).setAlignment(Align.center);
    if(setPosition){
      actor.setX(actor.getX() - actor.getWidth() / 2);
      actor.setY(actor.getY() - actor.getHeight() / 2);
    }
  }
  return this;
}

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

actor.setOrigin(widget.getAnchorPoint().getScaleX() * actor.getWidth(),
    widget.getAnchorPoint().getScaleY() * actor.getHeight());

相关文章