Example #1
0
  public void init() {

    scriptUI.runCompiler(TestNode.CollisionData.class);
    setUpControlMenu();
    disp.getJFrame().setJMenuBar(menuBar);
    disp.setTitle("Snap2D PhysicsUI - alpha v.0.2");
    disp.show();
    initWorld();
    rc.setTargetFPS(30);
    rc.setTargetTPS(30);
    rc.setRenderOp(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_SPEED);
    rc.startRenderLoop();
  }
Example #2
0
  public void addEntity(final PhysicsEntity pe, final int pos) {

    // rc.addRenderable(pe, pos);
    manager.register(pe, collListener);
    entities.add(pe);
    rc.addRenderable(pe, 1);
  }
Example #3
0
  public void showViewUI() {

    if (!isDialogShowing) {
      rc.setRenderActive(false);
      new ViewEntityUI(new PUICallback(), entities).setVisible(true);
      isDialogShowing = true;
    }
  }
Example #4
0
  public void showEntityUI() {

    if (scriptUI.getScriptProgram().findFunction(TestNode.COLL_FUNC_NAME) == null) {
      JOptionPane.showMessageDialog(null, "Can't find script function: " + TestNode.COLL_FUNC_NAME);
      return;
    }

    if (!isDialogShowing) {
      rc.setRenderActive(false);
      new AddEntityUI().setVisible(true);
      isDialogShowing = true;
    }
  }
Example #5
0
  PhysicsUI() {

    GraphicsConfig config = GraphicsConfig.getDefaultSystemConfig();
    config.set(Property.USE_OPENGL, "true");
    config.set(Property.USE_LINUX_XRENDER, "false");
    config.set(Property.SNAP2D_PRINT_RENDER_STAT, "false");
    disp = new Display(800, 600, Type.WINDOWED, config);
    rc = disp.getRenderControl(3);
    rc.addRenderable(new Background(), 0);
    rc.addRenderable(new InfoDisplay(), 1);
    registerKeyClient(
        new KeyEventClient() {

          @Override
          public void processKeyEvent(final KeyEvent e) {

            if (e.getID() == KeyEvent.KEY_PRESSED && e.getKeyCode() == KeyEvent.VK_SPACE) {
              rc.setDisableUpdates(rc.isUpdating());
            }
          }
        });

    registerMouseClient(new EntityClickMovement());
  }