Exemplo n.º 1
0
 protected void processTouchDragged() {
   int dropX = 0;
   int dropY = 0;
   if (!locked) {
     boolean moveActor = false;
     if (actorDrag) {
       synchronized (objects) {
         dropX = this.input.getTouchX() - this.getScreenX();
         dropY = this.input.getTouchY() - this.getScreenY();
         if (dragActor == null) {
           dragActor = getSynchronizedObject(dropX, dropY);
         }
         if (dragActor != null && dragActor.isDrag()) {
           synchronized (dragActor) {
             objects.sendToFront(dragActor);
             RectBox rect = dragActor.getBoundingRect();
             int dx = dropX - (rect.width / 2);
             int dy = dropY - (rect.height / 2);
             if (dragActor.getLLayer() != null) {
               dragActor.setLocation(dx, dy);
               dragActor.drag(dropX, dropY);
               if (dragActor.actorListener != null) {
                 dragActor.actorListener.drag(dropX, dropY);
               }
             }
             moveActor = true;
           }
         }
       }
     }
     if (!moveActor) {
       if (isNotMoveInScreen(
           this.input.getTouchDX() + this.x(), this.input.getTouchDY() + this.y())) {
         return;
       }
       if (getContainer() != null) {
         getContainer().sendToFront(this);
       }
       dropX = this.input.getTouchDX();
       dropY = this.input.getTouchDY();
       this.move(dropX, dropY);
       this.drag(dropX, dropY);
     }
   } else {
     if (!actorDrag) {
       return;
     }
     synchronized (objects) {
       dropX = this.input.getTouchX() - this.getScreenX();
       dropY = this.input.getTouchY() - this.getScreenY();
       if (dragActor == null) {
         dragActor = getSynchronizedObject(dropX, dropY);
       }
       if (dragActor != null && dragActor.isDrag()) {
         synchronized (dragActor) {
           objects.sendToFront(dragActor);
           RectBox rect = dragActor.getBoundingRect();
           int dx = dropX - (rect.width / 2);
           int dy = dropY - (rect.height / 2);
           if (dragActor.getLLayer() != null) {
             dragActor.setLocation(dx, dy);
             dragActor.drag(dropX, dropY);
             if (dragActor.actorListener != null) {
               dragActor.actorListener.drag(dropX, dropY);
             }
           }
         }
       }
     }
   }
 }
Exemplo n.º 2
0
 /**
  * 根据旋转方向移动坐标
  *
  * @param distance
  */
 public void move(double distance) {
   double angle = Math.toRadians(getRotation());
   int x = (int) Math.round(getX() + Math.cos(angle) * distance);
   int y = (int) Math.round(getY() + Math.sin(angle) * distance);
   setLocation(x, y);
 }
Exemplo n.º 3
0
 public void bottomOn(final Actor object) {
   object.setLocation(getWidth() / 2 - object.getWidth() / 2, getHeight() - object.getHeight());
 }
Exemplo n.º 4
0
 public void rightOn(final Actor object) {
   object.setLocation(getWidth() - object.getWidth(), getHeight() / 2 - object.getHeight() / 2);
 }
Exemplo n.º 5
0
 public void leftOn(final Actor object) {
   object.setLocation(0, getHeight() / 2 - object.getHeight() / 2);
 }
Exemplo n.º 6
0
 public void topOn(final Actor object) {
   object.setLocation(getWidth() / 2 - object.getWidth() / 2, 0);
 }
Exemplo n.º 7
0
 public void centerOn(final Actor object) {
   object.setLocation(
       getWidth() / 2 - object.getWidth() / 2, getHeight() / 2 - object.getHeight() / 2);
 }