Пример #1
0
 public void vflip() {
   for (PipAnimateFramePiece piece : pieces) {
     if (piece instanceof PipAni4AniFramePiece) {
       piece.dy = -piece.dy;
     } else {
       piece.transition = PipImage.vflip(piece.transition);
       piece.dy = -piece.dy - piece.getHeight();
       if (piece.rotate != 0) {
         int angle = ((piece.rotate % 360) + 360) % 360;
         piece.rotate = (piece.rotate - angle) + (360 - angle);
       }
     }
   }
 }
Пример #2
0
 /**
  * 当一个图块被拆分以后,调整用到被拆分的图块的帧。
  *
  * @param imgID
  * @param frame
  * @param splitPlan
  */
 public void onImageSplit(int imgID, int frame, int[][] splitPlan, int oldw, int oldh) {
   for (int i = pieces.size() - 1; i >= 0; i--) {
     PipAnimateFramePiece p = pieces.get(i);
     if (p.imageID == imgID && p.frame == frame) {
       pieces.remove(i);
       for (int j = 0; j < splitPlan.length; j++) {
         PipAnimateFramePiece newp = new PipAnimateFramePiece(this, imgID, frame + j);
         newp.transition = p.transition;
         int bx = splitPlan[j][0];
         int by = splitPlan[j][1];
         int bw = splitPlan[j][2];
         int bh = splitPlan[j][3];
         switch (p.transition) {
           case 1: // 垂直翻转
             newp.dx = p.dx + bx;
             newp.dy = p.dy + oldh - bh - by;
             break;
           case 2: // 水平翻转
             newp.dx = p.dx + oldw - bw - bx;
             newp.dy = p.dy + by;
             break;
           case 3: // 垂直+水平翻转
             newp.dx = p.dx + oldw - bw - bx;
             newp.dy = p.dy + oldh - bh - by;
             break;
           case 4: // 水平翻转+逆时针90度
             newp.dx = p.dx + by;
             newp.dy = p.dy + bx;
             break;
           case 5: // 顺时针90度
             newp.dx = p.dx + oldh - bh - by;
             newp.dy = p.dy + bx;
             break;
           case 6: // 逆时针90度
             newp.dx = p.dx + by;
             newp.dy = p.dy + oldw - bw - bx;
             break;
           case 7: // 水平翻转+顺时针90度
             newp.dx = p.dx + oldh - bh - by;
             newp.dy = p.dy + oldw - bw - bx;
             break;
           default:
             newp.dx = p.dx + bx;
             newp.dy = p.dy + by;
             break;
         }
         pieces.add(i + j, newp);
       }
     } else if (p.imageID == imgID && p.frame > frame) {
       p.frame += splitPlan.length - 1;
     }
   }
 }