Beispiel #1
0
        public void handleMessage(Message msg) {
          Ball B;
          for (int idx = 0; idx < arBall.size(); idx++) {
            B = arBall.get(idx);
            B.Move(getWidth(), getHeight());
            if (B.count > 4) {
              arBall.remove(idx);
              idx--;
            }
          }

          invalidate();
          mHandler.sendEmptyMessageDelayed(0, DELAY);
        }
Beispiel #2
0
 // 새로운 볼 생성
 public boolean onTouchEvent(MotionEvent event) {
   if (event.getAction() == MotionEvent.ACTION_DOWN) {
     Ball NewBall = Ball.Create((int) event.getX(), (int) event.getY(), RAD);
     arBall.add(NewBall);
     invalidate();
     return true;
   }
   return false;
 }
Beispiel #3
0
  // 새로운 볼 생성
  static Ball Create(int x, int y, int Rad) {
    Random Rnd = new Random();
    Ball NewBall = new Ball();

    NewBall.x = x;
    NewBall.y = y;
    NewBall.rad = Rad;
    do {
      NewBall.dx = Rnd.nextInt(11) - 5;
      NewBall.dy = Rnd.nextInt(11) - 5;
    } while (NewBall.dx == 0 || NewBall.dy == 0);

    NewBall.count = 0;
    NewBall.color = Color.rgb(Rnd.nextInt(256), Rnd.nextInt(256), Rnd.nextInt(256));

    return NewBall;
  }