private void handleRotateCharTouchEvent(TouchEvent touchEvent) {
    if (touchEvent.isActionDown()
        && Boundary.BoundaryUtils.isIntersecting(this.baPlayerBoundary, this.baTouchBoundary)) {
      this.isRotatingSkin = true;
      this.rotateCharInitalTouchX = touchEvent.getX();
      this.sRotateChar.setAlpha(1f);
    } else if (touchEvent.isActionUp()) {
      this.isRotatingSkin = false;
      this.sRotateChar.setAlpha(1f);
    }

    if (this.isRotatingSkin)
      if (touchEvent.isActionMove()) {
        final float DELTA = this.rotateCharInitalTouchX - touchEvent.getX();
        final float DELTA_ABS = Math.abs(DELTA);

        if (DELTA_ABS > MainMenuEditPlayer.ROTATE_MOVE_SENSITIVITY) {
          final int STEPS =
              (int) Math.floor(DELTA_ABS / MainMenuEditPlayer.ROTATE_MOVE_SENSITIVITY);

          MainMenuEditPlayer.skinMoveDirectionIndex += (DELTA > 0) ? STEPS : -STEPS;

          if (MainMenuEditPlayer.skinMoveDirectionIndex < 0)
            MainMenuEditPlayer.skinMoveDirectionIndex += Direction.values().length - 1;
          else if (MainMenuEditPlayer.skinMoveDirectionIndex > Direction.values().length - 2)
            MainMenuEditPlayer.skinMoveDirectionIndex -= Direction.values().length - 2;
          this.rotateCharInitalTouchX = touchEvent.getX();
          this.directPlayerSkin();
        }
      }
  }
Пример #2
0
    @Override
    public boolean onAreaTouched(
        TouchEvent pSceneTouchEvent, float pTouchAreaLocalX, float pTouchAreaLocalY) {
      if (!this.isVisible()) {
        return true;
      }
      if (pSceneTouchEvent.isActionDown()) {
        this.clearEntityModifiers();
        A19_10_POMI.play();
      } else if (pSceneTouchEvent.isActionMove()) {
        this.setPosition(
            pSceneTouchEvent.getX() - this.getWidth() / 2,
            pSceneTouchEvent.getY() - this.getHeight() / 2);
        if (checkContains(
            mFingerAnimatedSprite[4],
            57,
            43,
            185,
            171,
            (int) pSceneTouchEvent.getX(),
            (int) pSceneTouchEvent.getY())) {

          babyDring();
          this.setPosition(this.PX, this.PY);
          this.setVisible(false);
        }
      } else if (pSceneTouchEvent.isActionUp()) {
        this.setPosition(this.PX, this.PY);
        this.rotateAction();
      }
      return true;
    }
    @Override
    public boolean onAreaTouched(
        TouchEvent pSceneTouchEvent, float pTouchAreaLocalX, float pTouchAreaLocalY) {

      if (pSceneTouchEvent.isActionDown()) {
        // Log.i(TAG, "Touch CubicTouch isActionDown");
        if (checkContains(
            mSuzuAniSprite, 113, 30, 251, 202, (int) pTouchAreaLocalX, (int) pTouchAreaLocalY)) {
          Log.i(TAG, "Touch to ActionSuzuShiShi !");
          actionSuzuShiShi();
          return true;
        }
        for (int i = 0; i < mCubicEntity.length; i++) {
          if (mCubicEntity[i].isVisible()
              && mCubicEntity[i]
                  .getCubicBody()
                  .contains(pSceneTouchEvent.getX(), pSceneTouchEvent.getY())) {
            pxMOVE = pSceneTouchEvent.getX();
            if (mCubicEntity[i].actionDown() > 0) {
              Log.i(TAG, "Touch CubicTouch > 0");
            } else {
              Log.i(TAG, "Touch CubicTouch < 0 " + i);
              CUBICID = i;
            }
            return true;
          }
        }
      } else if (pSceneTouchEvent.isActionMove()) {
        // Log.i(TAG, "Touch CubicTouch isActionMove");
      } else if (pSceneTouchEvent.isActionUp()) {
        Log.i(TAG, "Touch CubicTouch isActionUp" + CUBICID);
        if (CUBICID >= 0 && mCubicEntity[CUBICID].getCubicAction() == CubicEntity.ACTION_DEFAULT) {
          float offset = pSceneTouchEvent.getX() - pxMOVE;
          if (offset < 0) {
            if (Math.abs(offset) >= 350) {
              Log.i(TAG, "Level 3");
              mCubicEntity[CUBICID].actionUp(CubicEntity.ACTION_TURN_LEVEL_3);
            } else if (Math.abs(offset) >= 200) {
              Log.i(TAG, "Level 2");
              mCubicEntity[CUBICID].actionUp(CubicEntity.ACTION_TURN_LEVEL_2);
            } else if (Math.abs(offset) >= 0) {
              Log.i(TAG, "Level 1");
              mCubicEntity[CUBICID].actionUp(CubicEntity.ACTION_TURN_LEVEL_1);
            }
          }
        }

        CUBICID = -1;
      }
      return super.onAreaTouched(pSceneTouchEvent, pTouchAreaLocalX, pTouchAreaLocalY);
    }
Пример #4
0
  @Override
  public boolean onAreaTouched(
      final TouchEvent pSceneTouchEvent,
      final float pTouchAreaLocalX,
      final float pTouchAreaLocalY) {
    if (!this.isEnabled()) {
      this.changeState(State.DISABLED);
    } else if (pSceneTouchEvent.isActionDown()) {
      if (this.mState != State.PRESSED) {
        doPressedDown(pTouchAreaLocalX, pTouchAreaLocalY);
      } else {
        doUnpressed(pTouchAreaLocalX, pTouchAreaLocalY);
      }
    } else if (pSceneTouchEvent.isActionCancel()) {
      doCancelled();
    } else if (pSceneTouchEvent.isActionUp()) {
      boolean contains = this.contains(pSceneTouchEvent.getX(), pSceneTouchEvent.getY());
      if (this.mState == State.PRESSED && !this.mIsBistable && contains) {
        doUnpressed(pTouchAreaLocalX, pTouchAreaLocalY);
      } else if (!contains) {
        doCancelled();
      }
    }

    return true;
  }
    @Override
    public boolean onAreaTouched(
        TouchEvent pSceneTouchEvent, float pTouchAreaLocalX, float pTouchAreaLocalY) {
      float pX = pSceneTouchEvent.getX();
      float pY = pSceneTouchEvent.getY();

      if (pSceneTouchEvent.isActionDown()) {
        if (checkContainsPolygon(mTabSprite[0], POINTER_FACE, 8, pX, pY)) {
          Log.i(TAG, "Touch to body Face !");
          actionFace();
        }

        if (mCubicChooseSpite[CUBIC_ORANGE].contains(pX, pY)
            && mCubicChooseSpite[CUBIC_ORANGE].isVisible()) {
          insertCubicToTab(CUBIC_ORANGE);
        } else if (mCubicChooseSpite[CUBIC_BLUE].contains(pX, pY)
            && mCubicChooseSpite[CUBIC_BLUE].isVisible()) {
          insertCubicToTab(CUBIC_BLUE);
        } else if (mCubicChooseSpite[CUBIC_GREEN].contains(pX, pY)
            && mCubicChooseSpite[CUBIC_GREEN].isVisible()) {
          insertCubicToTab(CUBIC_GREEN);
        } else if (mCubicChooseSpite[CUBIC_YELLOW].contains(pX, pY)
            && mCubicChooseSpite[CUBIC_YELLOW].isVisible()) {
          insertCubicToTab(CUBIC_YELLOW);
        }
      }
      return super.onAreaTouched(pSceneTouchEvent, pTouchAreaLocalX, pTouchAreaLocalY);
    }
Пример #6
0
  @Override
  public boolean onAreaTouched(
      TouchEvent pSceneTouchEvent, float pTouchAreaLocalX, float pTouchAreaLocalY) {

    int action = pSceneTouchEvent.getAction();

    switch (action) {
      case TouchEvent.ACTION_UP:
        if (mState
            == BallState.MOVING) { // ball state needed because actionup was being called twice
          handleReleaseSprite(pSceneTouchEvent);
          mState = BallState.STOPPED;
        }
        break;
      case TouchEvent.ACTION_DOWN:
        if (mState == BallState.STOPPED) {
          baseBoardX = board.getBoardXfromYCoord(getAngleY(this.mY));
          baseBoardY = board.getBoardYfromXCoord(getAngleX(this.mX));
          mState = BallState.MOVING;
        }

      default:
        if (mState == BallState.MOVING) {
          this.setPosition(
              pSceneTouchEvent.getX() - this.getWidth() / 2,
              pSceneTouchEvent.getY() - this.getHeight() / 2);
        }
        break;
    }

    return true;
  }
 @Override
 protected Camera getCameraFromSurfaceTouchEvent(final TouchEvent pTouchEvent) {
   if (pTouchEvent.getX() <= this.mSurfaceWidth >> 1) {
     return this.getFirstCamera();
   } else {
     return this.getSecondCamera();
   }
 }
  public void onTapFromGame(TouchEvent event) {
    Debug.d("tap on " + event.getX() + "x" + event.getY());

    //		SoundLibrary.playSample(Sample.LASER); //AG: lo he movido a TouchProcess

    //		SoundLibrary.playSample(Sample.CHEWAKA);
    //		SoundLibrary.stopSample(Sample.CHEWAKA, true, 2);
  }
Пример #9
0
  @Override
  public boolean onSceneTouchEvent(TouchEvent pSceneTouchEvent) {

    if (pSceneTouchEvent.isActionDown() && !personajeSaltando) {
      personajeSaltando = true;
      // Animar sprite central
      JumpModifier salto =
          new JumpModifier(
              1,
              spritePersonaje.getX(),
              spritePersonaje.getX(),
              spritePersonaje.getY(),
              spritePersonaje.getY(),
              -200);
      RotationModifier rotacion = new RotationModifier(1, 360, 0);
      ParallelEntityModifier paralelo =
          new ParallelEntityModifier(salto, rotacion) {
            @Override
            protected void onModifierFinished(IEntity pItem) {
              personajeSaltando = false;
              unregisterEntityModifier(this);
              super.onModifierFinished(pItem);
            }
          };
      spritePersonaje.registerEntityModifier(paralelo);
    }

    if (pSceneTouchEvent.isActionDown()) {
      // El usuario toca la pantalla
      float x = pSceneTouchEvent.getX();
      float y = pSceneTouchEvent.getY();
      spritePersonaje.setPosition(x, y);
    }
    if (pSceneTouchEvent.isActionMove()) {
      // El usuario mueve el dedo sobre la pantalla
      float x = pSceneTouchEvent.getX();
      float y = pSceneTouchEvent.getY();
      spritePersonaje.setPosition(x, y);
    }
    if (pSceneTouchEvent.isActionUp()) {
      // El usuario deja de tocar la pantalla
    }

    return super.onSceneTouchEvent(pSceneTouchEvent);
  }
  @Override
  public boolean onSceneTouchEvent(Scene scene, TouchEvent touchEvent) {
    if (super.mmsContext.getDialog() != null && super.mmsContext.getDialog().isShowing()) {
      return ((DialogScene) super.mmsContext).onSceneTouchEvent(touchEvent);
    }

    if (this.sCurrent != null && this.sCurrent.isShowing())
      return this.sCurrent.onSceneTouchEvent(scene, touchEvent);

    if (this.baTouchBoundary == null)
      this.baTouchBoundary = new BoundaryAdapter(touchEvent.getX(), touchEvent.getY(), 1f, 1f);
    else this.baTouchBoundary.set(touchEvent.getX(), touchEvent.getY(), 1f, 1f);

    this.handleRotateCharTouchEvent(touchEvent);

    final boolean scrollContainerEvent =
        !this.isRotatingSkin && this.scLeftSideContainer.onTouchEvent(touchEvent);
    if (!scrollContainerEvent) return super.onSceneTouchEvent(scene, touchEvent);
    else return true;
  }
Пример #11
0
  public void testConvertSceneToSurfaceTouchEventNonCenter() {
    this.mCamera.setCenter(0, 0);

    final TouchEvent touchEvent = TouchEvent.obtain(-50, -50, TouchEvent.ACTION_DOWN, 0, null);

    final int surfaceWidth = 100;
    final int surfaceHeight = 100;

    this.mCamera.convertSceneToSurfaceTouchEvent(touchEvent, surfaceWidth, surfaceHeight);

    Assert.assertEquals(0, touchEvent.getX(), DELTA);
    Assert.assertEquals(0, touchEvent.getY(), DELTA);
  }
Пример #12
0
  @Override
  public boolean onSceneTouchEvent(Scene pScene, TouchEvent pSceneTouchEvent) {

    if (pSceneTouchEvent.isActionDown()) {
      int cX = (int) pSceneTouchEvent.getX();
      int cY = (int) pSceneTouchEvent.getY(); /*
			int cX = (int)pSceneTouchEvent.getMotionEvent().getX();
			int cY = (int)pSceneTouchEvent.getMotionEvent().getY();*/
      // this.targetX = this.currX + (cX - this.CAMERA_WIDTH/2);
      // this.targetY = this.currY + (cY - this.CAMERA_HEIGHT/2);
      this.targetX = cX;
      this.targetY = cY;
      // TODO: border case
      // scene.attachChild(new Sprite(cX,cY, this.mLouisTextureRegion,
      // getVertexBufferObjectManager()));
      /*
      dX = 10;
      dY = 10;
      System.out.print("clicked!");
      if (pSceneTouchEvent.getX() < CAMERA_WIDTH/2)
      {
      	dX = -10;
      }
      if (pSceneTouchEvent.getY() < CAMERA_HEIGHT/2)
      {
      	dY = -10;
      }*/

      // cene.clearChildScene();

      /*if (counter < text.length - 1)
      	counter++;
      mText = new Text(100, 40, mFont, text[counter], new TextOptions(HorizontalAlign.CENTER), this.getVertexBufferObjectManager());
      scene.attachChild(backgroundSprite);
      if (counter % 2 == 0)
      	scene.attachChild(mRobin);
      else
      	scene.attachChild(mLouis);
      scene.attachChild(mText);*/
      return true;
    }
    /*
    if (pSceneTouchEvent.isActionMove())
    {
    	pScene.attachChild(mRobin);
    	return true;
    }*/

    return false;
  }
Пример #13
0
        @Override
        public boolean onAreaTouched(
            TouchEvent pSceneTouchEvent,
            ITouchArea pTouchArea,
            float pTouchAreaLocalX,
            float pTouchAreaLocalY) {
          newPlayerPositionX = pSceneTouchEvent.getX();
          newPlayerPositionY = pSceneTouchEvent.getY();
          oldPlayerPositionX = playerSprite.getX();
          oldPlayerPositionY = playerSprite.getY();

          System.out.println("NewPosition:" + newPlayerPositionX + "," + newPlayerPositionY);

          return true;
        }
Пример #14
0
  public float handleSceneTouch(TouchEvent pSceneTouchEvent) {
    Vector2 v =
        new Vector2(
            getHead().getX() - pSceneTouchEvent.getX(), getHead().getY() - pSceneTouchEvent.getY());

    float angle = v.getAngle();
    if ((0 <= angle && angle <= 45) || (315 < angle && angle < 360)) {
      setDirection(SnakeDirection.RIGHT);
    } else if (45 < angle && angle <= 135) {
      setDirection(SnakeDirection.UP);
    } else if (135 < angle && angle <= 225) {
      setDirection(SnakeDirection.LEFT);
    } else if (225 < angle && angle <= 315) {
      setDirection(SnakeDirection.DOWN);
    }
    return angle;
  }
Пример #15
0
  /**
   * When the user releases the ball
   *
   * @param t
   */
  private void handleReleaseSprite(TouchEvent t) {
    int releaseBoardY = board.getBoardYfromXCoord(t.getX());
    int releaseBoardX = board.getBoardXfromYCoord(t.getY());

    // if something happens I restore the ball in its original place
    try {
      board.moveBall(baseBoardX, baseBoardY, releaseBoardX, releaseBoardY);

      setPosition(releaseBoardX, releaseBoardY);
    } catch (CantMoveException e) {
      setPosition(baseBoardX, baseBoardY);
    } catch (CantFillException e) {
      setPosition(baseBoardX, baseBoardY);
    }

    baseBoardX = 0;
    baseBoardY = 0;
  }
Пример #16
0
  @Override
  public boolean onSceneTouchEvent(Scene pScene, TouchEvent pSceneTouchEvent) {
    if (pSceneTouchEvent.getAction() == TouchEvent.ACTION_DOWN) {
      int pX = (int) pSceneTouchEvent.getX();
      int pY = (int) pSceneTouchEvent.getY();

      if (mKaigaAnimatedSprite.contains(pX, pY)) {
        nextTileAnimatedSprite(mKaigaAnimatedSprite);
        A19_04_SAKUTON2.play();
      } else if (mTvAnimatedSprite.contains(pX, pY) && isTv && isHand) {
        isHand = false;
        tvAction();
        babyDontCry();
        resetBaby();
      } else if (checkContains(mClockAnimatedSprite, 29, 0, 171, 171, pX, pY) && isClock) {
        clockAction();
      } else if (checkContains(mDoorAnimatedSprite, 144, 26, 218, 383, pX, pY)
          && isDoor
          && isHand) {
        isHand = false;
        doorAction();
        babyDontCry();
        resetBaby();
      } else if (checkContains(mHandDefaultSprite, 227, 312, 454, 426, pX, pY) && isHand) {
        isHand = false;
        jankenAction();
        resetBaby();
      }
    }
    if (pSceneTouchEvent.isActionUp()) {
      if (mTempFringerAnimatedSprite != null) {
        if (mTempFringerAnimatedSprite.isAnimationRunning()) {
          mTempFringerAnimatedSprite.stopAnimation(0);
          mTempFringerAnimatedSprite = null;
        }
      }
      Log.d(TAG, " upup ,,,,,,,,,,,,,,,,,,,");
    }
    return true;
  }
Пример #17
0
    @Override
    public boolean onAreaTouched(
        TouchEvent pSceneTouchEvent, float pTouchAreaLocalX, float pTouchAreaLocalY) {

      if (isUongSua) {
        return true;
      }

      int pX = (int) pSceneTouchEvent.getX();
      int pY = (int) pSceneTouchEvent.getY();
      switch (pSceneTouchEvent.getAction()) {
        case TouchEvent.ACTION_DOWN:
          if (this.idIndex == 4 && !isBabyCry) {
            break;
          }
          if (isHand) {
            this.isOK = true;
            this.isMove = false;
            if (this.isAnimationRunning()) {
              break;
            }
            if (checkContains(
                this,
                FringerPointer[this.idIndex][0],
                FringerPointer[this.idIndex][1],
                FringerPointer[this.idIndex][2],
                FringerPointer[this.idIndex][3],
                pX,
                pY)) {
              Log.d(TAG, "Touch Mat: " + this.idIndex);
              this.type = 2;
              SFringerFace[this.idIndex].play();
            } else if (checkContains(
                this,
                FringerPointer[this.idIndex][4],
                FringerPointer[this.idIndex][5],
                FringerPointer[this.idIndex][6],
                FringerPointer[this.idIndex][7],
                pX,
                pY)) {
              Log.d(TAG, "Touch Bung: " + this.idIndex);
              this.type = 1;
              SFringerBody[this.idIndex].play();
            }
            Log.d(TAG, "idIndex: " + this.idIndex);
            if (this.type > 0) {
              this.pXTouch = pSceneTouchEvent.getX();
              this.pYTouch = pSceneTouchEvent.getY();
              this.setCurrentTileIndex(FringerAction[this.type][0]);
              this.animate(new long[] {1000, 100}, new int[] {FringerAction[this.type][0], 0}, 0);
              mTempFringerAnimatedSprite = this;
            }
          }
          break;
        case TouchEvent.ACTION_MOVE:
          if (this.idIndex == 4 && !isBabyCry) {
            break;
          }
          if (!this.isAnimationRunning()
              && !this.isMove
              && (pSceneTouchEvent.getX() + pSceneTouchEvent.getY()) - (this.pXTouch + this.pYTouch)
                  >= 10) {
            this.isMove = true;
            if (this.type == 2) {
              this.type = 3;
              this.setCurrentTileIndex(FringerAction[this.type][0]);
              SFringerFaceMove[this.idIndex].play();
            } else if (this.type == 1) {
              this.type = 4;
              this.animate(
                  new long[] {300, 300},
                  new int[] {FringerAction[this.type][0], FringerAction[this.type][1]},
                  -1);
              SFringerBodyMove[this.idIndex].play();
            }
          }

          if (this.isMove) {
            if (this.type == 3) {
              if (!checkContains(
                  this,
                  FringerPointer[this.idIndex][0],
                  FringerPointer[this.idIndex][1],
                  FringerPointer[this.idIndex][2],
                  FringerPointer[this.idIndex][3],
                  pX,
                  pY)) {
                this.isOK = false;
                if (this.isAnimationRunning()) {
                  this.stopAnimation();
                }
                Log.d(TAG, "Ngoai mat");
                this.setCurrentTileIndex(0);
              }
            } else if (this.type == 4) {
              if (!checkContains(
                  this,
                  FringerPointer[this.idIndex][4],
                  FringerPointer[this.idIndex][5],
                  FringerPointer[this.idIndex][6],
                  FringerPointer[this.idIndex][7],
                  pX,
                  pY)) {
                this.isOK = false;
                if (this.isAnimationRunning()) {
                  this.stopAnimation();
                }
                Log.d(TAG, "Ngoai bung");
                this.setCurrentTileIndex(0);
              }
            }
          }

          break;
        case TouchEvent.ACTION_UP:
          if (this.idIndex == 4 && !isBabyCry) {
            break;
          }
          this.type = 0;
          Log.d(TAG, "ACTION_UP: " + this.isMove + "/ " + this.idIndex);

          if (this.isMove) {
            this.setCurrentTileIndex(FringerAction[this.type][0]);
          }
          if (this.isAnimationRunning()) {
            this.stopAnimation(0);
          }
          this.isOK = true;
          break;
      }
      return false;
    }
Пример #18
0
  @Override
  public boolean onSceneTouchEvent(final Scene pScene, final TouchEvent pSceneTouchEvent) {
    final VertexBufferObjectManager vertexBufferObjectManager =
        activity.getVertexBufferObjectManager();
    // FixtureDef objectFixtureDef = PhysicsFactory.createFixtureDef(0.0f,
    //       0.0f, 0.0f);

    // centerText.detachSelf();

    if (linesDrawn <= 150) {
      if (pSceneTouchEvent.getAction() == TouchEvent.ACTION_DOWN) {
        isDrawing = true;
        i = 0;
      }
      if (pSceneTouchEvent.getAction() == TouchEvent.ACTION_UP) {
        isDrawing = false;
      }
      if (isDrawing = true) {
        rec[i] =
            new Rectangle(
                pSceneTouchEvent.getX(), pSceneTouchEvent.getY(), 1, 1, vertexBufferObjectManager);
        if (i != 0) {
          Line l =
              new Line(rec[i - 1].getX(), rec[i - 1].getY(), rec[i].getX(), rec[i].getY(), null);
          Line bodyLine =
              new Line(rec[i - 1].getX(), rec[i - 1].getY(), rec[i].getX(), rec[i].getY(), null);
          Body lb;
          Line line =
              new Line(rec[i - 1].getX(), rec[i - 1].getY(), rec[i].getX(), rec[i].getY(), null);
          lb = PhysicsFactory.createLineBody(mPhysicsWorld, bodyLine, wallFixtureDef);
          lb.setUserData("line");
          line.setLineWidth(5);
          bodyLine.setVisible(false);
          line.setColor(Color.WHITE);
          bodyLine.setColor(Color.WHITE);
          attachChild(bodyLine);
          attachChild(line);
          linesDrawn++;
          rectangle(linesDrawn);
        }
        linesDrawn++;
        i++;

        // final Text elapsedText = new Text(500, 360, activity.mFont, "Seconds elapsed:", "Seconds
        // elapsed: XXXXX".length(), activity.getVertexBufferObjectManager());
        // final Text fpsText = new Text(500, 400, activity.mFont, "FPS:", "FPS: XXXXX".length(),
        // activity.getVertexBufferObjectManager());

        // attachChild(elapsedText);
        // attachChild(fpsText);

        // final FPSCounter fpsCounter = new FPSCounter();

        //	registerUpdateHandler(new TimerHandler(1 / 20.0f, true, new ITimerCallback() {
        //		@Override
        //		public void onTimePassed(final TimerHandler pTimerHandler) {
        //			elapsedText.setText("Globs Used: " + linesDrawn);
        // fpsText.setText("Globs Left: " + ( 150 - linesDrawn));
        //		}
        //	}));
        //  }

      }
    }
    return true;
  }
Пример #19
0
  /** TODO So ugly :( Maybe make it its own class? */
  @Override
  public boolean onSceneTouchEvent(final Scene pScene, final TouchEvent pSceneTouchEvent) {
    final Float x = pSceneTouchEvent.getX();
    final Float y = pSceneTouchEvent.getY();

    currentTile = this.tmxLayer.getTMXTileAt(x, y);

    // if the user pinches or dragtouches the screen then...
    if (this.mPinchZoomDetector != null) {

      this.mPinchZoomDetector.onTouchEvent(pSceneTouchEvent);
      if (this.mPinchZoomDetector.isZooming()) {
        this.mScrollDetector.setEnabled(false);
      } else if (!towerMove) {
        if (pSceneTouchEvent.isActionDown()) {
          this.mScrollDetector.setEnabled(true);
        }
        this.mScrollDetector.onTouchEvent(pSceneTouchEvent);
      }

    } else {
      this.mScrollDetector.onTouchEvent(pSceneTouchEvent);
    }

    if (pSceneTouchEvent.isActionDown()) {
      downCoords.set(x, y);

      SubMenuManager.setReticalPosition(-500.0f, -500.0f);

      Log.i("Detaching now", "NOW");
      SubMenuManager.remove();
      this.unregisterTouchArea(SubMenuManager.getDeleteSprite());

      panel.detachTowerUpgradeDeleteText();
      panel.detachTowerTextDescription();
      panel.attachTowerTextDescription(pointOnTile(TouchEvent.ACTION_DOWN));
    }

    Class<?> tClass;
    if (pSceneTouchEvent.isActionMove()) {

      tClass = pointOnTile(TouchEvent.ACTION_MOVE);
      if (tClass != null && !towerMove) {
        dragTower = null;
        towerMove = true;
        if (tClass.equals(TurretTower.class) && canAfford(TurretTower.COST)) {
          dragTower = new TurretTower(x, y, resourceManager.getTurretTowerRegion());
        } else if (tClass.equals(DartTower.class) && canAfford(DartTower.COST)) {
          dragTower = new DartTower(x, y, resourceManager.getDartTowerRegion());
        } else if (tClass.equals(FlameTower.class) && canAfford(FlameTower.COST)) {
          dragTower = new FlameTower(x, y, resourceManager.getFlameTowerRegion());
        } else if (tClass.equals(IceTower.class) && canAfford(IceTower.COST)) {
          dragTower = new IceTower(x, y, resourceManager.getIceTowerRegion());
        } else if (tClass.equals(SpikeTower.class) && canAfford(SpikeTower.COST)) {
          dragTower = new SpikeTower(x, y, resourceManager.getSpikeTowerRegion());
        } else towerMove = false;

        if (dragTower != null) {
          dragTower.getEntity().setZIndex(2);
          dragTower.getEntity().setScale(0.5f);

          activity.runOnUpdateThread(
              new Runnable() {
                @Override
                public void run() {
                  attachChild(dragTower.getEntity());

                  try {
                    attachChild(SubMenuManager.getReticle(dragTower));
                  } catch (Exception e) {
                  }
                  sortChildren();
                }
              });
          tClass = null;
        }

      }

      // Moving an active drag tower
      else if (towerMove) {
        if (pointOnMap(x, y)) {

          dragTower.setPosition(
              currentTile.getTileX() - GameMap.getTileSize() / 2,
              currentTile.getTileY() - GameMap.getTileSize() / 2);

          if (highlightTile == null) {
            highlightTile =
                new Rectangle(
                    currentTile.getTileX(),
                    currentTile.getTileY(),
                    GameMap.getTileSize(),
                    GameMap.getTileSize(),
                    activity.getVertexBufferObjectManager());
            highlightTile.setTag(777);
            highlightTile.setZIndex(1);
            this.attachChild(highlightTile);
            this.sortChildren();
          } else {
            highlightTile.setPosition(currentTile.getTileX(), currentTile.getTileY());
          }

          if (!inLegitimatePosition(currentTile)) {
            highlightTile.setColor(Color.RED);
          } else {
            highlightTile.setColor(Color.BLUE);
          }

          // if you drag the dragtower off the map, and then back on, we need to be able to tag it
          // so we can display the highlight tile again
          if (this.getChildByTag(777) == null) {
            this.attachChild(highlightTile);
            this.sortChildren();
          }
        }
        // if point NOT on map
        else {
          if (highlightTile != null) {
            detachHighlightTile();
          }
          dragTower.setPosition(
              pSceneTouchEvent.getX() - dragTower.getEntity().getWidth() / 2,
              pSceneTouchEvent.getY() - dragTower.getEntity().getHeight() / 2);
        }
      }
    } else if (pSceneTouchEvent.isActionUp()) {

      if (zooming) {
        fingerOnSceneCount--;

        if (fingerOnSceneCount == 0) {
          zooming = false;
          setUserDataforTowerTiles("");

          for (TowerTile tile : panel.getTiles()) {
            tile.returnOnMoved();
          }
        }
      }

      if (towerMove) {
        towerMove = false;

        if (currentTile != null
            && highlightTile != null
            && highlightTile.getColor().equals(Color.BLUE)) {

          // Add the tile to the blocked list
          blockedTileList.add(currentTile);

          towers.add(dragTower);
          SubMenuManager.getReticle(dragTower).detachSelf();

          // need to get it out of the scene so that the next dragtower doesn't have to start with
          // it from where the
          // previous tower was placed
          SubMenuManager.setReticalPosition(-500.0f, -500.0f);

          // Nothing is free in this world
          this.payAmount(dragTower.getCost());

          // If we are in the middle of a wave, the AStarPath class must update
          // the path since there is now a new tower on the field
          updateAffectedEnemies(currentTile, aStarHelper.isNavigating());
        } else {
          removeCurrentTower(false);
        }

        if (highlightTile != null) {
          detachHighlightTile();
        }
      } else if (Math.abs(downCoords.x - x) < 15.0f && Math.abs(downCoords.y - y) < 15.0f) {

        final ITower tower = pointOnExistingTower(x, y);
        if (tower != null) {
          this.attachChild(SubMenuManager.display(tower));
          Log.i("Reticle", "Visible? " + SubMenuManager.getReticle(tower).isVisible() + "");
          panel.attachTowerUpgradeDeleteText(tower);

          if (camera.getZoomFactor() - 1.0f < 0.00005f && camera.getYMin() < 0.00005f) {

            final float displacement = tower.getRadius() - tower.getEntity().getHeightScaled() / 2;
            if (tower.getY() == -20.0f) {
              camera.set(
                  camera.getXMin(),
                  camera.getYMin() - displacement,
                  camera.getXMax(),
                  camera.getYMax() - displacement);
            } else if (tower.getY() == 340.0f) {
              camera.set(
                  camera.getXMin(),
                  camera.getYMin() + displacement,
                  camera.getXMax(),
                  camera.getYMax() + displacement);
            }
          }
        }
      }
    }
    return true;
  }