示例#1
0
 public void mousePressed(MainState state, int x, int y) {
   for (SkinObject obj : objects) {
     if (obj.getClickevent() != -1) {
       boolean draw = true;
       for (int op : obj.getOption()) {
         boolean soption = false;
         if (op > 0) {
           for (int sop : option) {
             if (op == sop) {
               soption = true;
               break;
             }
           }
         } else {
           soption = true;
           for (int sop : option) {
             if (-op == sop) {
               soption = false;
               break;
             }
           }
         }
         if (soption) {
           continue;
         }
         final boolean b = state.getBooleanValue(op);
         if ((op > 0 && !b) || (op < 0 && b)) {
           draw = false;
           break;
         }
       }
       if (draw) {
         Rectangle r = obj.getDestination(state.getNowTime(), state);
         System.out.println(
             obj.getClickevent()
                 + " : "
                 + r.x
                 + ","
                 + r.y
                 + ","
                 + r.width
                 + ","
                 + r.height
                 + " - "
                 + x
                 + ","
                 + y);
         if (r != null && r.x <= x && r.x + r.width >= x && r.y <= y && r.y + r.height >= y) {
           state.executeClickEvent(obj.getClickevent());
         }
       }
     }
   }
 }
示例#2
0
 public void drawAllObjects(SpriteBatch sprite, MainState state) {
   final long time = state.getNowTime();
   for (SkinObject obj : objects) {
     boolean draw = true;
     for (int op : obj.getOption()) {
       boolean soption = false;
       if (op > 0) {
         for (int sop : option) {
           if (op == sop) {
             soption = true;
             break;
           }
         }
       } else {
         soption = true;
         for (int sop : option) {
           if (-op == sop) {
             soption = false;
             break;
           }
         }
       }
       if (soption) {
         continue;
       }
       final boolean b = state.getBooleanValue(op);
       if ((op > 0 && !b) || (op < 0 && b)) {
         draw = false;
         break;
       }
     }
     if (draw) {
       obj.draw(sprite, time, state);
     }
   }
 }
示例#3
0
 public void mouseDragged(MainState state, int x, int y) {
   final long time = state.getNowTime();
   for (SkinObject obj : objects) {
     if (obj instanceof SkinSlider && ((SkinSlider) obj).isChangable()) {
       final SkinSlider slider = (SkinSlider) obj;
       boolean draw = true;
       for (int op : obj.getOption()) {
         boolean soption = false;
         if (op > 0) {
           for (int sop : option) {
             if (op == sop) {
               soption = true;
               break;
             }
           }
         } else {
           soption = true;
           for (int sop : option) {
             if (-op == sop) {
               soption = false;
               break;
             }
           }
         }
         if (soption) {
           continue;
         }
         final boolean b = state.getBooleanValue(op);
         if ((op > 0 && !b) || (op < 0 && b)) {
           draw = false;
           break;
         }
       }
       if (draw) {
         Rectangle r = obj.getDestination(time, state);
         if (r != null) {
           int sa = slider.getSliderAngle();
           switch (sa) {
             case 0:
               if (r.x <= x && r.x + r.width >= x && r.y <= y && r.y + slider.getRange() >= y) {
                 state.setSliderValue(slider.getType(), (y - r.y) / slider.getRange());
               }
               break;
             case 1:
               if (r.x <= x && r.x + slider.getRange() >= x && r.y <= y && r.y + r.height >= y) {
                 state.setSliderValue(slider.getType(), (x - r.x) / slider.getRange());
               }
               break;
             case 2:
               if (r.x <= x && r.x + r.width >= x && r.y - slider.getRange() <= y && r.y >= y) {
                 state.setSliderValue(slider.getType(), (r.y - y) / slider.getRange());
               }
               break;
             case 3:
               if (r.x <= x && r.x + slider.getRange() >= x && r.y <= y && r.y + r.height >= y) {
                 state.setSliderValue(
                     slider.getType(), (r.x + slider.getRange() - x) / slider.getRange());
               }
               break;
           }
         }
       }
     }
   }
 }