Ejemplo n.º 1
0
 /** onGlassButtonClicked(). */
 public void onGlassClicked(String paramString) {
   switch (this.gridMode) {
     case 1:
       try {
         for (int i = 0; i <= SharedData.getInstance().glassList.size(); i++) {
           if ((((Glass) SharedData.getInstance().glassList.get(i))
               .getId()
               .equalsIgnoreCase(paramString))) {
             SharedData.getInstance().player.usedGlass =
                 ((Glass) SharedData.getInstance().glassList.get(i));
             ((Activity) Director.getInstance().getContext())
                 .runOnUiThread(
                     new Runnable() {
                       @Override
                       public void run() {
                         Toast.makeText(
                                 Director.getInstance().getContext(),
                                 "Button Clicked",
                                 Toast.LENGTH_LONG)
                             .show();
                       }
                     });
           } else if ((((Glass) SharedData.getInstance().glassList.get(i)).isLocked())) {
           }
         }
       } catch (final java.lang.IndexOutOfBoundsException e) {
         Log.d("ALGORITHMI", "Index Out of bound exception: ", e);
         ((Activity) Director.getInstance().getContext())
             .runOnUiThread(
                 new Runnable() {
                   @Override
                   public void run() {
                     AlertDialog.Builder builder =
                         new AlertDialog.Builder(Director.getInstance().getContext());
                     builder
                         .setIcon(R.drawable.algo_logo2)
                         .setMessage(" ERROR: " + e)
                         .setPositiveButton(
                             "KILL PROESS",
                             new DialogInterface.OnClickListener() {
                               @Override
                               public void onClick(DialogInterface arg0, int arg1) {
                                 arg0.cancel();
                               }
                             });
                     AlertDialog dialog = builder.create();
                     dialog.show();
                   }
                 });
       }
   }
 }
Ejemplo n.º 2
0
 public void jDraw() {
   if (mHasViewport) {
     WYSize s = Director.getInstance().getWindowSize();
     GL10 gl = Director.getInstance().gl;
     gl.glColor4f(0.0f, 1.0f, 0.0f, 1.0f);
     gl.glLineWidth(1);
     WYPoint[] vertices = {
       WYPoint.make(50, 50),
       WYPoint.make(s.width - 50, 50),
       WYPoint.make(s.width - 50, s.width - 50),
       WYPoint.make(50, s.width - 50)
     };
     Primitives.drawPoly(vertices, true);
   }
 }
Ejemplo n.º 3
0
    void reset() {
      // clear result
      m_result.clear();

      // relocate sprite
      WYSize s = Director.getInstance().getWindowSize();
      m_sprite1.setRotation(Utilities.rand(360));
      m_sprite1.setPosition(0, 0);
      m_sprite2.setRotation(Utilities.rand(360));
      m_sprite2.setPosition(s.width, s.height);

      // re-run actions
      MoveBy move1 = MoveBy.make(4, s.width, s.height);
      move1.autoRelease();
      RotateBy rotate1 = RotateBy.make(4, Utilities.rand(360));
      rotate1.autoRelease();
      m_sprite1.runAction(move1);
      m_sprite1.runAction(rotate1);
      MoveBy move2 = MoveBy.make(4, -s.width, -s.height);
      move2.autoRelease();
      RotateBy rotate2 = RotateBy.make(4, Utilities.rand(360));
      rotate2.autoRelease();
      m_sprite2.runAction(move2);
      m_sprite2.runAction(rotate2);
    }
Ejemplo n.º 4
0
    public MyLayer() {
      // add label
      WYSize s = Director.getInstance().getWindowSize();
      Label label = Label.make("", 22, "DroidSans", Typeface.BOLD, 0);
      label.setColor(new WYColor3B(0, 0, 0));

      // sprite for button
      NinePatchSprite normal =
          NinePatchSprite.make(
              Texture2D.makePNG(R.drawable.textbox_normal),
              ResolutionIndependent.resolve(WYRect.make(11, 21, 1, 1)));
      NinePatchSprite pressed =
          NinePatchSprite.make(
              Texture2D.makePNG(R.drawable.textbox_pressed),
              ResolutionIndependent.resolve(WYRect.make(11, 21, 1, 1)));
      NinePatchSprite focused =
          NinePatchSprite.make(
              Texture2D.makePNG(R.drawable.textbox_focused),
              ResolutionIndependent.resolve(WYRect.make(11, 21, 1, 1)));
      normal.setContentSize(DP(280), DP(42));
      pressed.setContentSize(DP(280), DP(42));
      focused.setContentSize(DP(280), DP(42));

      // 通过addContentView添加一个EditText到场景中,它实际上是盖在WYGLSurfaceView上面
      TextBox box = TextBox.make(normal, pressed, null, focused, label);
      box.setPosition(s.width / 2, s.height / 2);
      box.setTitle("Input something!");
      box.setMessage("试试中文的提示怎么样");
      box.setPositiveButton("想修改就点我");
      box.setNegativeButton("Oh No!");
      box.setPadding(DP(10), DP(3), DP(10), DP(6));
      box.setCallback(this);
      addChild(box);
    }
Ejemplo n.º 5
0
 @Override
 public boolean onBackButton() {
   SharedData.getInstance().soundsHandler.playButtonClickSound();
   Director.getInstance()
       .replaceScene((TransitionScene) LeftPushInTransition.make(0.5f, new FruitSelectedScene()));
   return true;
 }
 public DecorationScene() {
   autoRelease(true);
   setTouchEnabled(true);
   this.actionHandler = new ActionHandler();
   this.wySize = Director.getInstance().getWindowSize();
   setContents();
 }
Ejemplo n.º 7
0
 public void visit(int bodyPointer, Object data) {
   Body body = Body.from(bodyPointer);
   if (body.getPositionY() < -260 || abs(body.getPositionX()) > 240) {
     WYSize s = Director.getInstance().getWindowSize();
     float x = frand() * s.width - s.width / 2;
     body.setPosition(x, 260);
   }
 }
Ejemplo n.º 8
0
    public MyLayer() {
      WYSize s = Director.getInstance().getWindowSize();
      mSprite = Sprite.make(R.drawable.grossini);
      mSprite.setPosition(s.width / 2, s.height / 2);
      addChild(mSprite);

      setDoubleTapEnabled(true);
    }
Ejemplo n.º 9
0
 /** Constructor. */
 public GlassSelection() {
   this.wySize = Director.getInstance().getWindowSize();
   this.actionHandler = new ActionHandler();
   this.glassSupport = new GlassSupport(this);
   setTouchEnabled(true);
   this.gateState = MODE_GATE_CLOSED;
   this.mode = MODE_TOUCH_GATE;
   setContents();
 }
Ejemplo n.º 10
0
    public MyLayer() {
      WYSize s = Director.getInstance().getWindowSize();
      Chipmunk chipmunk = Chipmunk.make();
      chipmunk.setDebugDraw(true);
      chipmunk.setPosition(s.width / 2, s.height / 2);
      addChild(chipmunk);

      mRandom = new Random();

      Shape.resetShapeIdCounter();

      mSpace = chipmunk.getSpace();
      mSpace.setIterations(5);
      mSpace.setGravity(0, -100);
      mSpace.resizeActiveHash(40f, 999);
      mSpace.resizeStaticHash(30f, 2999);

      Body staticBody = Body.make(Float.MAX_VALUE, Float.MAX_VALUE);

      // Create vertexes for a pentagon shape.
      WYPoint[] verts = new WYPoint[5];
      for (int i = 0; i < NUM_VERTS; i++) {
        float angle = -2 * (float) Math.PI * i / (NUM_VERTS);
        verts[i] = WYPoint.make(10 * (float) cos(angle), 10 * (float) sin(angle));
      }

      // Vertexes for a triangle shape.
      WYPoint tris[] = {WYPoint.make(-15, -15), WYPoint.make(0, 10), WYPoint.make(15, -15)};

      // Create the static triangles.
      for (int i = 0; i < 9; i++) {
        for (int j = 0; j < 6; j++) {
          float stagger = (j % 2) * 40;
          WYPoint offset = WYPoint.make(i * 80 - s.width / 2 + stagger, j * 70 - s.width / 2);
          Poly shape = Poly.make(staticBody, tris, offset);
          shape.setRestitution(1f);
          shape.setFriction(1f);
          shape.setLayerMask(Chipmunk.NOT_GRABABLE_MASK);
          mSpace.addStaticShape(shape);
        }
      }

      // Add lots of pentagons
      float moment = Chipmunk.calculateMomentForPoly(1f, verts, WYPoint.makeZero());
      for (int i = 0; i < 50; i++) {
        Body body = Body.make(1f, moment);
        float x = frand() * s.width - s.width / 2;
        body.setPosition(x, s.height / 2 * 5 / 7);
        mSpace.addBody(body);

        Poly shape = Poly.make(body, verts, WYPoint.makeZero());
        shape.setFriction(0.4f);
        mSpace.addShape(shape);
      }

      schedule(new TargetSelector(this, "update(float)", new Object[] {0f}));
    }
 @Override
 public void onSoftNextButtonClicked() {
   SharedData.getInstance().soundsHandler.playButtonClickSound();
   Director.getInstance()
       .replaceScene(
           (TransitionScene) RightPushInTransition.make(0.5f, new EndGameScene()).autoRelease());
   this.particleSystem.stopAllActions();
   this.particleSystem.setVisible(false);
   VunglePub.displayAdvert();
 }
 /** @return boolean */
 @Override
 public boolean onBackButton() {
   SharedData.getInstance().soundsHandler.playButtonClickSound();
   Director.getInstance()
       .replaceScene(
           (TransitionScene)
               LeftPushInTransition.make(0.5f, new HotDrinkSelectionScene()).autoRelease());
   this.particleSystem.stopAllActions();
   this.particleSystem.setVisible(false);
   return true;
 }
Ejemplo n.º 13
0
    public MyLayer() {
      WYSize s = Director.getInstance().getWindowSize();
      Sprite sprite = Sprite.make(R.drawable.grossini);
      addChild(sprite);
      sprite.setPosition(s.width / 2, s.height / 2);

      IntervalAction a = (IntervalAction) FadeTo.make(2, 255, 0).autoRelease();
      IntervalAction r = (IntervalAction) a.reverse().autoRelease();
      IntervalAction seq = (IntervalAction) Sequence.make(a, r).autoRelease();
      Action repeat = (Action) RepeatForever.make(seq).autoRelease();
      sprite.runAction(repeat);
    }
Ejemplo n.º 14
0
 @Override
 public boolean onDoubleTap(MotionEvent e) {
   int idx = Utilities.rand(14) + 1;
   Context context = Director.getInstance().getContext();
   int id =
       context
           .getResources()
           .getIdentifier(
               String.format("grossini_dance_%02d", idx), "drawable", context.getPackageName());
   mSprite.setTexture(Texture2D.makePNG(id));
   return true;
 }
Ejemplo n.º 15
0
  private void makeItemLockedDialog() {
    ((Activity) Director.getInstance().getContext())
        .runOnUiThread(
            new Runnable() {
              @Override
              public void run() {
                final AlertDialog.Builder builder =
                    new AlertDialog.Builder(Director.getInstance().getContext());
                builder
                    .setIcon(R.drawable.algo_logo2)
                    .setMessage(
                        "The Item requested is not available "
                            + "in Juice Maker Free version. Please upgrade to "
                            + "Juice Maker Pro version from"
                            + " Google Play Store. To Download now press 'Download' "
                            + "button, To Download later press"
                            + " 'Later' "
                            + "to exit")
                    .setTitle(" Alert")
                    .setPositiveButton(
                        "Download",
                        new DialogInterface.OnClickListener() {
                          @Override
                          public void onClick(DialogInterface arg0, int arg1) {
                            try {
                              ((Activity) Director.getInstance().getContext())
                                  .startActivity(
                                      new Intent(
                                          "android.intent.action.VIEW",
                                          Uri.parse(
                                              "market://details?id="
                                                  + "com.algorithmi.maker.juice.main")));
                            } catch (ActivityNotFoundException ae) {

                            }
                          }
                        })
                    .setNegativeButton(
                        "Later",
                        new DialogInterface.OnClickListener() {
                          @Override
                          public void onClick(DialogInterface arg0, int arg1) {
                            arg0.dismiss();
                          }
                        });
                AlertDialog dialog = builder.create();
                dialog.show();
              }
            });
  }
Ejemplo n.º 16
0
    @Override
    public boolean wyKeyDown(KeyEvent event) {
      switch (event.getKeyCode()) {
        case KeyEvent.KEYCODE_MENU:
          mHasViewport = !mHasViewport;
          if (mHasViewport) {
            WYSize s = Director.getInstance().getWindowSize();
            mMap.setClipRect(WYRect.make(50, 50, s.width - 100, s.width - 100));
          } else {
            mMap.clearClipRect();
          }
          break;
      }

      return false;
    }
 /**
  * @param event
  * @return boolean
  */
 @Override
 public boolean wyTouchesMoved(MotionEvent event) {
   WYPoint point = Director.getInstance().convertToGL(event.getX(), event.getY());
   switch (this.mode) {
     case _MODE_DRAG_ADDON:
       if (this.addOnSprite.getBoundingBoxRelativeToWorld().containsPoint(point)) {
         this.addOnSprite.setPosition(point);
       } else if (this.cupSprite.getBoundingBoxRelativeToWorld().containsPoint(point)) {
         this.cupSprite.setPosition(point);
       }
       break;
     default:
       break;
   } // end switch
   return true;
 }
 private void makeToastDrink() {
   ((Activity) Director.getInstance().getContext())
       .runOnUiThread(
           new Runnable() {
             @Override
             public void run() {
               Toast toast =
                   Toast.makeText(
                       Director.getInstance().getContext(),
                       "This item is locked!" + " Please upgrade to pro version to unlock",
                       Toast.LENGTH_LONG);
               toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
               toast.show();
             }
           });
 }
Ejemplo n.º 19
0
    @Override
    public boolean wyTouchesBegan(MotionEvent event) {
      TMXLayer layer = mMap.getTMXLayerAt(0);
      WYPoint loc = Director.getInstance().convertToGL(event.getX(), event.getY());
      loc = layer.convertToNodeSpace(loc.x, loc.y);
      WYDimension d = layer.getTileCoordinateAt(loc.x, loc.y);
      WYPoint pos = layer.getPositionAt(d.x, d.y);
      if (d.x != -1) {
        mSprite.setVisible(true);
        mSprite.setPosition(pos.x + layer.getTileWidth() / 2, pos.y + layer.getTileHeight() / 2);
      } else {
        mSprite.setVisible(false);
      }

      mLastX = event.getX();
      mLastY = event.getY();
      return true;
    }
Ejemplo n.º 20
0
    @Override
    public void jDraw() {
      if (m_result.pointCount > 0) {
        // draw collision point
        GL10 gl = Director.getInstance().gl;
        gl.glColor4f(1, 0, 0, 1);
        gl.glPointSize(5);
        Primitives.drawPoints(m_result.getPoints());

        // draw normal
        Primitives.drawLine(
            m_result.points[0].x,
            m_result.points[0].y,
            m_result.points[0].x + m_result.normal.x * 50,
            m_result.points[0].y + m_result.normal.y * 50);

        gl.glColor4f(1, 1, 1, 1);
      }
    }
Ejemplo n.º 21
0
    public MyLayer() {
      Texture2D tex1 = Texture2D.make(R.drawable.ortho_test1);
      tex1.autoRelease();
      Texture2D tex2 = Texture2D.make(R.drawable.ortho_test1_bw);
      tex2.autoRelease();
      mMap = TMXTileMap.make(R.raw.orthogonal_test5, tex1, tex2);
      addChild(mMap);

      // add click feedback sprite
      Texture2D tex = Texture2D.make(R.drawable.blocks);
      mSprite = Sprite.make(tex, ResolutionIndependent.resolve(WYRect.make(0, 0, 32, 32)));
      mSprite.setVisible(false);
      mMap.addChild(mSprite, 10);

      // add a hint label
      WYSize s = Director.getInstance().getWindowSize();
      Label label = Label.make("(Menu)Switch Clip", 16);
      label.setPosition(s.width / 2, s.height - 30);
      addChild(label);

      setTouchEnabled(true);
      setKeyEnabled(true);
      setJavaVirtualMethods(this);
    }
Ejemplo n.º 22
0
 private void setPouringScene() {
   Director.getInstance()
       .replaceScene((TransitionScene) RightPushInTransition.make(0.5f, new PouringScene()));
   VunglePub.displayAdvert();
 }
Ejemplo n.º 23
0
  /**
   * @param event android.view.MotionEvent
   * @return boolean true
   */
  @Override
  public boolean wyTouchesBegan(MotionEvent event) {
    WYPoint point = Director.getInstance().convertToGL(event.getX(), event.getY());
    switch (this.mode) {
      case MODE_TOUCH_GATE:
        if ((this.almirahGate.getBoundingBoxRelativeToWorld().containsPoint(point))
            && (this.gateState == MODE_GATE_CLOSED)) {
          this.almirahGate.runAction(
              MoveTo.make(
                  1.0f,
                  this.almirahGate.getPositionX(),
                  this.almirahGate.getPositionY(),
                  this.wySize.width / 2.0f - (this.almirahGate.getWidth() - 50.0f),
                  this.almirahGate.getPositionY()));

          this.particle.runAction(
              MoveTo.make(1.0f, this.particle.getPositionX(), point.y, -300.0f, point.y));

          this.gateState = MODE_GATE_OPEN;
          this.glassMode = GLASS_MODE_TOUCH_ENABLED_TRUE;
        } else if (this.almirahGate.getBoundingBoxRelativeToWorld().containsPoint(point)
            && (this.gateState == MODE_GATE_OPEN)) {
          this.almirahGate.runAction(
              MoveTo.make(
                  1.0f,
                  this.almirahGate.getPositionX(),
                  this.almirahGate.getPositionY(),
                  this.wySize.width / 2.0f,
                  this.almirahGate.getPositionY()));

          this.particle.runAction(
              MoveTo.make(
                  1.0f,
                  this.particle.getPositionX(),
                  point.y,
                  this.wySize.width + 300.0f,
                  point.y));
          this.gateState = MODE_GATE_CLOSED;
          this.glassMode = GLASS_MODE_TOUCH_ENABLED_FALSE;
        }

        // glass01
        if ((this.glass01.getBoundingBoxRelativeToWorld().containsPoint(point))
            && (this.almirahGate.getPositionX()
                == this.wySize.width / 2.0f - (this.almirahGate.getWidth() - 50.0f))) {
          if (SharedData.getInstance().glassList.get(0).isLocked()) {
            makeItemLockedDialog();
          } else {
            SharedData.getInstance().player.usedGlass = SharedData.getInstance().glassList.get(0);
            setPouringScene();
          }
        } else // glass02
        if ((this.glass02.getBoundingBoxRelativeToWorld().containsPoint(point))
            && (this.almirahGate.getPositionX()
                == this.wySize.width / 2.0f - (this.almirahGate.getWidth() - 50.0f))) {
          if (SharedData.getInstance().glassList.get(1).isLocked()) {
            makeItemLockedDialog();
          } else {
            SharedData.getInstance().player.usedGlass = SharedData.getInstance().glassList.get(1);
            setPouringScene();
          }
        } else // glass03
        if ((this.glass03.getBoundingBoxRelativeToWorld().containsPoint(point))
            && (this.almirahGate.getPositionX()
                == this.wySize.width / 2.0f - (this.almirahGate.getWidth() - 50.0f))) {
          if (SharedData.getInstance().glassList.get(2).isLocked()) {
            makeItemLockedDialog();
          } else {
            SharedData.getInstance().player.usedGlass = SharedData.getInstance().glassList.get(2);
            setPouringScene();
          }
        } else // glass04
        if ((this.glass04.getBoundingBoxRelativeToWorld().containsPoint(point))
            && (this.almirahGate.getPositionX()
                == this.wySize.width / 2.0f - (this.almirahGate.getWidth() - 50.0f))) {
          if (SharedData.getInstance().glassList.get(3).isLocked()) {
            makeItemLockedDialog();
          } else {
            SharedData.getInstance().player.usedGlass = SharedData.getInstance().glassList.get(3);
            setPouringScene();
          }
        } else // glass05
        if ((this.glass05.getBoundingBoxRelativeToWorld().containsPoint(point))
            && (this.almirahGate.getPositionX()
                == this.wySize.width / 2.0f - (this.almirahGate.getWidth() - 50.0f))) {
          if (SharedData.getInstance().glassList.get(4).isLocked()) {
            makeItemLockedDialog();
          } else {
            SharedData.getInstance().player.usedGlass = SharedData.getInstance().glassList.get(4);
            setPouringScene();
          }
        } else // glass06
        if ((this.glass06.getBoundingBoxRelativeToWorld().containsPoint(point))
            && (this.almirahGate.getPositionX()
                == this.wySize.width / 2.0f - (this.almirahGate.getWidth() - 50.0f))) {
          if (SharedData.getInstance().glassList.get(5).isLocked()) {
            makeItemLockedDialog();
          } else {
            SharedData.getInstance().player.usedGlass = SharedData.getInstance().glassList.get(5);
            setPouringScene();
          }
        } else // glass07
        if ((this.glass07.getBoundingBoxRelativeToWorld().containsPoint(point))
            && (this.almirahGate.getPositionX()
                == this.wySize.width / 2.0f - (this.almirahGate.getWidth() - 50.0f))) {
          if (SharedData.getInstance().glassList.get(6).isLocked()) {
            makeItemLockedDialog();
          } else {
            SharedData.getInstance().player.usedGlass = SharedData.getInstance().glassList.get(6);
            setPouringScene();
          }
        } else // glass08
        if ((this.glass08.getBoundingBoxRelativeToWorld().containsPoint(point))
            && (this.almirahGate.getPositionX()
                == this.wySize.width / 2.0f - (this.almirahGate.getWidth() - 50.0f))) {
          if (SharedData.getInstance().glassList.get(7).isLocked()) {
            makeItemLockedDialog();
          } else {
            SharedData.getInstance().player.usedGlass = SharedData.getInstance().glassList.get(7);
            setPouringScene();
          }
        } else // glass09
        if ((this.glass09.getBoundingBoxRelativeToWorld().containsPoint(point))
            && (this.almirahGate.getPositionX()
                == this.wySize.width / 2.0f - (this.almirahGate.getWidth() - 50.0f))) {
          if (SharedData.getInstance().glassList.get(8).isLocked()) {
            makeItemLockedDialog();
          } else {
            SharedData.getInstance().player.usedGlass = SharedData.getInstance().glassList.get(8);
            setPouringScene();
          }
        } else // glass10
        if ((this.glass10.getBoundingBoxRelativeToWorld().containsPoint(point))
            && (this.almirahGate.getPositionX()
                == this.wySize.width / 2.0f - (this.almirahGate.getWidth() - 50.0f))) {
          if (SharedData.getInstance().glassList.get(9).isLocked()) {
            makeItemLockedDialog();
          } else {
            SharedData.getInstance().player.usedGlass = SharedData.getInstance().glassList.get(9);
            setPouringScene();
          }
        }

        break;
      default:
        break;
    }
    return true;
  }
Ejemplo n.º 24
0
 @Override
 protected String checkPrecondition() {
   return Director.getInstance().isExtensionSupported("GL_OES_framebuffer_object")
       ? null
       : "Your device doesn't support frame buffer object, this demo will not work";
 }
Ejemplo n.º 25
0
 private void setEmitterPosition() {
   WYSize s = Director.getInstance().getWindowSize();
   emitter.setPosition(s.width / 2, s.height / 2);
 }
Ejemplo n.º 26
0
 @Override
 public boolean wyTouchesBegan(MotionEvent event) {
   WYPoint loc = Director.getInstance().convertToGL(event.getX(), event.getY());
   emitter.setPosition(loc.x, loc.y);
   return true;
 }