Exemple #1
0
 public boolean intersects(Actor other) {
   int thisBounds1;
   if (this.image == null) {
     if (other.image != null) {
       thisBounds1 = this.gameLayer.getCellSize();
       return other.containsPoint(
           location.x() * thisBounds1 + thisBounds1 / 2,
           location.y() * thisBounds1 + thisBounds1 / 2);
     } else {
       return location.x == other.location.x && location.y == other.location.y;
     }
   } else if (other.image == null) {
     thisBounds1 = this.gameLayer.getCellSize();
     return this.containsPoint(
         other.location.x() * thisBounds1 + thisBounds1 / 2,
         other.location.y() * thisBounds1 + thisBounds1 / 2);
   } else {
     RectBox thisBounds = this.getBoundingRect();
     RectBox otherBounds = other.getBoundingRect();
     if (this.rotation == 0 && other.rotation == 0) {
       return thisBounds.intersects(otherBounds);
     } else if (!thisBounds.intersects(otherBounds)) {
       return false;
     } else {
       int[] myX = this.xs;
       int[] myY = this.ys;
       int[] otherX = other.xs;
       int[] otherY = other.ys;
       return checkOutside(myX, myY, otherX, otherY)
           ? false
           : !checkOutside(otherX, otherY, myX, myY);
     }
   }
 }
Exemple #2
0
 protected void processTouchPressed() {
   if (!isTouchClick) {
     return;
   }
   if (this.input.getTouchPressed() == MouseEvent.BUTTON1) {
     int dx = this.input.getTouchX() - this.getScreenX();
     int dy = this.input.getTouchY() - this.getScreenY();
     dragActor = getSynchronizedObject(dx, dy);
     if (dragActor != null) {
       if (dragActor.isClick()) {
         dragActor.downClick(dx, dy);
         if (dragActor.actorListener != null) {
           dragActor.actorListener.downClick(dx, dy);
         }
       }
     }
     this.downClick(dx, dy);
   }
 }
Exemple #3
0
 public void moveCamera(Actor actor) {
   moveCamera(actor.getX(), actor.getY());
 }
Exemple #4
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);
             }
           }
         }
       }
     }
   }
 }
Exemple #5
0
 public void bottomOn(final Actor object) {
   object.setLocation(getWidth() / 2 - object.getWidth() / 2, getHeight() - object.getHeight());
 }
Exemple #6
0
 public void rightOn(final Actor object) {
   object.setLocation(getWidth() - object.getWidth(), getHeight() / 2 - object.getHeight() / 2);
 }
Exemple #7
0
 public void leftOn(final Actor object) {
   object.setLocation(0, getHeight() / 2 - object.getHeight() / 2);
 }
Exemple #8
0
 public void topOn(final Actor object) {
   object.setLocation(getWidth() / 2 - object.getWidth() / 2, 0);
 }
Exemple #9
0
 public void centerOn(final Actor object) {
   object.setLocation(
       getWidth() / 2 - object.getWidth() / 2, getHeight() / 2 - object.getHeight() / 2);
 }
Exemple #10
0
 public void paintObjects(LGraphics g, int minX, int minY, int maxX, int maxY) {
   if (objects == null) {
     return;
   }
   synchronized (objects) {
     int paintSeq = 0;
     boolean isListener = false;
     Iterator iter = objects.iterator();
     Actor thing = null;
     while (iter.hasNext()) {
       thing = (Actor) iter.next();
       if (!thing.isVisible()) {
         continue;
       }
       isListener = (thing.actorListener != null);
       thing.update(elapsedTime);
       if (isListener) {
         thing.actorListener.update(elapsedTime);
       }
       RectBox rect = thing.getRectBox();
       int actorX = minX + thing.getX();
       int actorY = minY + thing.getY();
       int actorWidth = rect.getWidth();
       int actorHeight = rect.getHeight();
       if (actorX + actorWidth < minX
           || actorX > maxX
           || actorY + actorHeight < minY
           || actorY > maxY) {
         continue;
       }
       LImage actorImage = thing.getImage();
       if (actorImage != null) {
         thing.setLastPaintSeqNum(paintSeq++);
         boolean isBitmapFilter = ImageFilterType.NoneFilter != thing.filterType;
         Image bitmap = actorImage.getBufferedImage();
         if (isBitmapFilter) {
           bitmap = factory.doFilter(bitmap, thing.filterType);
         }
         int rotation = thing.getRotation();
         if (thing.alpha < 1.0) {
           g.setAlpha(thing.alpha);
         }
         if (rotation != 0) {
           double halfWidth = actorImage.getWidth() / 2;
           double halfHeight = actorImage.getHeight() / 2;
           double newWidth = actorX + halfWidth;
           double newHeight = actorY + halfHeight;
           atform.setToIdentity();
           atform.scale(thing.scaleX, thing.scaleY);
           atform.translate(newWidth, newHeight);
           atform.rotate(Math.toRadians(rotation));
           atform.translate(-newWidth, -newHeight);
           atform.translate(actorX, actorY);
           g.drawImage(bitmap, atform);
         } else {
           int width = (int) (actorImage.getWidth() * thing.scaleX);
           int height = (int) (actorImage.getHeight() * thing.scaleY);
           g.drawImage(bitmap, actorX, actorY, width, height);
         }
         if (isBitmapFilter) {
           bitmap.flush();
           bitmap = null;
         }
         if (thing.alpha < 1.0) {
           g.setAlpha(1.0F);
         }
       }
       if (actorX == 0 && actorY == 0) {
         thing.draw(g);
         if (isListener) {
           thing.actorListener.draw(g);
         }
       } else {
         g.translate(actorX, actorY);
         thing.draw(g);
         if (isListener) {
           thing.actorListener.draw(g);
         }
         g.translate(-actorX, -actorY);
       }
     }
   }
 }