Beispiel #1
0
  /**
   * Creates a {@link ModelEntity}. This method should only be invoked if the return value of the
   * {@link #save()} method was true.
   */
  public void createSceneElement() {
    ModelEntity savedElement =
        this.controller.getTemplates().createSceneElement(this.savePath.path());

    Actor rootGroup = scaledView.getGroupEditorDragListener().getRootGroup();

    Actor scaledAct = rootGroup == null ? scaledView : rootGroup;

    savedElement.setScaleX(1 / scaledAct.getScaleX());
    savedElement.setScaleY(1 / scaledAct.getScaleY());
    Vector2 pos = mesh.getPosition();

    savedElement.setX(pos.x - scaledAct.getX());
    savedElement.setY(pos.y - scaledAct.getY());

    Q.getComponent(savedElement, RepoElement.class).setThumbnail(thumbSavePath.name());

    this.controller.action(AddSceneElement.class, savedElement);
  }
Beispiel #2
0
  @Override
  protected void doBuild() {
    ModelEntity scene = singleSceneGame(null, 800, 600).getLastScene();

    ModelEntity rectangle = new ModelEntity();
    rectangle.getComponents().add(rectangle(400, 300));
    scene.getChildren().add(rectangle);

    Shader shader = new Shader();
    shader.setUri("gradient.fragment");

    shader.getUniforms().add(param("point1", "f0,f0"));
    shader.getUniforms().add(param("point2", "f1,f1"));
    shader.getUniforms().add(param("color1", "f1,f1,f1,f1"));
    shader.getUniforms().add(param("color2", "f0,f0,f0,f1"));

    rectangle.getComponents().add(shader);

    rectangle = new ModelEntity();
    rectangle.getComponents().add(rectangle(400, 300));
    rectangle.setX(400);

    shader = new Shader();
    shader.setUri("gradient.fragment");

    shader.getUniforms().add(param("point1", "f0,f0"));
    shader.getUniforms().add(param("point2", "f1,f1"));
    shader.getUniforms().add(param("color1", "f1,f1,f1,f1"));
    shader.getUniforms().add(param("color2", "f0,f0,f0,f1"));

    rectangle.getComponents().add(shader);

    scene.getChildren().add(rectangle);

    rectangle = new ModelEntity();
    rectangle.getComponents().add(rectangle(400, 300));
    rectangle.setY(300);

    shader = new Shader();
    shader.setUri("gradient.fragment");

    shader.getUniforms().add(param("point1", "f0.25,f0.25"));
    shader.getUniforms().add(param("point2", "f0.75,f0.75"));
    shader.getUniforms().add(param("color1", "f1,f0,f0,f1"));
    shader.getUniforms().add(param("color2", "f0,f1,f0,f1"));

    rectangle.getComponents().add(shader);

    scene.getChildren().add(rectangle);

    rectangle = new ModelEntity();
    rectangle.getComponents().add(rectangle(400, 300));
    rectangle.setX(400);
    rectangle.setY(300);

    shader = new Shader();
    shader.setUri("gradient.fragment");

    shader.getUniforms().add(param("point1", "f0,f0"));
    shader.getUniforms().add(param("point2", "f0,f1"));
    shader.getUniforms().add(param("color1", "f0,f1,f1,f1"));
    shader.getUniforms().add(param("color2", "f1,f0,f1,f1"));

    rectangle.getComponents().add(shader);

    scene.getChildren().add(rectangle);
  }