コード例 #1
0
ファイル: TextButton.java プロジェクト: ryoenji/commons-gdx
  public TextButton(BitmapFont font, CharSequence text, float x, float y) {
    this.font = font;
    this.text = text;
    setX(x);
    setY(y);
    // colorTransition = Transitions.transitionBuilder(notOverColor).build();
    colorTransition = Transitions.transition(notOverColor).build();
    this.cx = 0.5f;
    this.cy = 0.5f;
    this.id = "";

    invalidate();
  }
コード例 #2
0
  @Override
  public void apply(Entity entity) {
    String spriteId = parameters.get("spriteId");

    // default world scale, considering viewport 800f
    float worldScale = 0.015625f;

    Float x = parameters.get("x");
    Float y = parameters.get("y");

    Float speed = parameters.get("speed");

    Integer layer = parameters.get("layer");

    Sprite sprite = resourceManager.getResourceValue(spriteId);
    if (sprite == null)
      throw new RuntimeException(
          "Failed to instantiate static sprite, " + spriteId + " not found.");

    entity.setGroup(Groups.Clouds);

    // SpriteUtils.resize(sprite, worldWidth);

    final float cloudSize = 2f;

    float width = sprite.getWidth() * worldScale * cloudSize;
    float height = sprite.getHeight() * worldScale * cloudSize;

    SpriteComponent spriteComponent = new SpriteComponent(sprite);

    spriteComponent.getColor().set(1f, 1f, 1f, 0f);
    Synchronizers.transition(
        spriteComponent.getColor(),
        Transitions.transitionBuilder().start(new Color(1f, 1f, 1f, 0f)).end(Color.WHITE).time(1f));

    entity.addComponent(new SpatialComponent(new SpatialImpl(x, y, width, height, 0f)));
    entity.addComponent(new PreviousStateSpatialComponent());
    entity.addComponent(spriteComponent);
    entity.addComponent(new RenderableComponent(layer));

    entity.addComponent(new BoundsComponent(new Rectangle(0f, 0f, width, height)));
    entity.addComponent(new MovementComponent(new Vector2(speed, 0f), 0f));
  }