示例#1
0
 public void setNextScene(Iscene nextScene, PImage arrow) {
   nextSceneInner = nextScene;
   // Button to get to the next scene
   MTImageButton nextSceneButton = new MTImageButton(arrow, mtApp);
   nextSceneButton.setNoStroke(true);
   if (MT4jSettings.getInstance().isOpenGlMode()) nextSceneButton.setUseDirectGL(true);
   nextSceneButton.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent ae) {
           switch (ae.getID()) {
             case TapEvent.BUTTON_CLICKED:
             case TapEvent.BUTTON_UP:
               // Save the current scene on the scene stack before changing
               mtApp.pushScene();
               mtApp.changeScene(nextSceneInner);
               break;
             default:
               break;
           }
         }
       });
   getCanvas().addChild(nextSceneButton);
   nextSceneButton.setPositionGlobal(
       new Vector3D(
           mtApp.width - nextSceneButton.getWidthXY(TransformSpace.GLOBAL) - 5,
           mtApp.height - nextSceneButton.getHeightXY(TransformSpace.GLOBAL) - 5,
           0));
 }
示例#2
0
  public SlideScene2(
      MTApplication mtApplication, String name, PImage pImage, boolean hasPrev, PImage arrow) {
    super(mtApplication, name);
    this.mtApp = mtApplication;

    // Set the background color
    this.setClearColor(new MTColor(0, 0, 0, 0));

    this.registerGlobalInputProcessor(new CursorTracer(mtApp, this));

    MTRectangle rect = new MTRectangle(pImage, mtApplication);
    this.getCanvas().addChild(rect);
    rect.setPositionGlobal(new Vector3D(mtApplication.width / 2f, mtApplication.height / 2f));

    if (hasPrev) {

      MTImageButton previousSceneButton = new MTImageButton(arrow, mtApplication);
      previousSceneButton.setNoStroke(true);
      if (MT4jSettings.getInstance().isOpenGlMode()) previousSceneButton.setUseDirectGL(true);
      previousSceneButton.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
              switch (ae.getID()) {
                case TapEvent.BUTTON_CLICKED:
                case TapEvent.BUTTON_UP:
                  mtApp.popScene();
                  break;
                default:
                  break;
              }
            }
          });
      getCanvas().addChild(previousSceneButton);
      previousSceneButton.scale(
          -1, 1, 1, previousSceneButton.getCenterPointLocal(), TransformSpace.LOCAL);
      previousSceneButton.setPositionGlobal(
          new Vector3D(
              previousSceneButton.getWidthXY(TransformSpace.GLOBAL) + 5,
              mtApp.height - previousSceneButton.getHeightXY(TransformSpace.GLOBAL) - 5,
              0));
    }

    // Set a scene transition - Flip transition only available using opengl supporting the FBO
    // extenstion
    if (MT4jSettings.getInstance().isOpenGlMode() && GLFBO.isSupported(mtApp))
      this.setTransition(new FlipTransition(mtApp, 700));
    else {
      this.setTransition(new FadeTransition(mtApp));
    }
  }