Esempio n. 1
0
  @Test
  public void testVisibility() {
    reset();

    ModelEntity entity = new ModelEntity();
    Visibility visibility = new Visibility();
    visibility.setCondition("(eq $" + variableDef + " i1)");
    entity.getComponents().add(visibility);

    entitiesLoader.toEngineEntity(entity);
    IntMap<Entity> entityIntMap =
        gameLoop.getEntitiesFor(Family.getFamilyFor(VisibilityComponent.class));
    EngineEntity engineEntity = (EngineEntity) entityIntMap.entries().next().value;
    assertTrue(engineEntity.getGroup().isVisible());

    gameLoop.update(1);
    assertFalse(engineEntity.getGroup().isVisible());

    variablesManager.setVarToExpression(variableDef, "i1");
    gameLoop.update(1);
    assertTrue(engineEntity.getGroup().isVisible());

    variablesManager.setVarToExpression(variableDef, "i0");
    gameLoop.update(1);
    assertFalse(engineEntity.getGroup().isVisible());
  }
Esempio n. 2
0
 private EngineEntity createModelEntityWithKeyboardInteraction(
     int keycode, boolean shift, boolean control, boolean alt, String condition) {
   ModelEntity modelEntity = new ModelEntity();
   Behavior behavior = new Behavior();
   key.setKeycode(keycode);
   key.setShift(shift);
   key.setCtrl(control);
   key.setAlt(alt);
   behavior.setEvent(key);
   behavior.getEffects().add(new MockEffect(this));
   modelEntity.getComponents().add(behavior);
   return addEntity(modelEntity);
 }
Esempio n. 3
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);
  }
Esempio n. 4
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);
  }