Ejemplo n.º 1
0
  public void onMouseMove(Location point) {

    if (gameOn) {
      theFish.moveTo(point.getX() - theFish.getWidth() / 2, point.getY());

      lastMouse = point;
      currentScore = theFish.getScore();
      score.setText("Score: " + currentScore);
      score.moveTo((canvas.getWidth() - score.getWidth()) / 2, 50);
    }
  }
Ejemplo n.º 2
0
 /**
  * method that will be called when mouse drags
  * @param point , the point mouse drag at
  */
 public void onMouseDrag(Location point){
   double xMovement = point.getX() - lastPoint.getX();
   double yMovement = point.getY() - lastPoint.getY();
   //get distance of movement
   
   if(!success){
     if(isGrabbed){
       grabbedPiece.move(xMovement, yMovement);
       lastPoint = point;
     }
   }
   else{
     if(isGrabbed){
       for(Piece p: bp){
         ((BoardPiece)p).move(xMovement, yMovement);
       }
       lastPoint = point;
     }
   }
 }