예제 #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);
    }
  }
예제 #2
0
파일: PuzzleEC.java 프로젝트: HowsenH/CSE11
 /**
  * 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;
     }
   }
 }