Ejemplo n.º 1
0
  public void studentCollidesWithMobileBlock(
      final Student mStudent, final AnimatedItemPool animationItemPool) {
    float AIX = getX();
    float AIY = getY();
    mStudent.unregisterListener();
    mStudent.recyclePath();
    mStudent.setTouchEnable(false);

    this.unregisterListener();
    finishedCheckCollidesWithBlock = true;
    changAnimateOfStudent(mStudent);
    changeDirectionWhenMeetStudent();

    // can chinh toa do cho dung' ung' voi tung` nhan vat, tung hieu ung'
    addanimationItem(AIX, AIY - 60, animationItemPool, mStudent);

    TimerHandler Timer2;

    float mEffectSpawnDelay2 = TIME_RELEASE;
    Timer2 =
        new TimerHandler(
            mEffectSpawnDelay2,
            false,
            new ITimerCallback() {
              @Override
              public void onTimePassed(TimerHandler pTimerHandler) {
                mStudent.setTouchEnable(true);
                finishedCheckCollidesWithBlock = false;
                // nhung Timer chi dung 1 lan, roi lan sau lai tao new TimerHandler thi can
                // unregister sau khi ket thuc
                LevelManager.getEngine().unregisterUpdateHandler(pTimerHandler);
              }
            });
    LevelManager.getEngine().registerUpdateHandler(Timer2);
  }
Ejemplo n.º 2
0
 private void changAnimateOfStudent(Student mStudent) {
   switch (Direction) {
     case 0: // AI's up
       //			mStudent.animate(new long[]{100}, new int[]{0}, 0);
       mStudent.stopAnimation(0);
       break;
     case 1: //  AI's right
       mStudent.stopAnimation(4);
       break;
     case 2: // AI's down
       mStudent.stopAnimation(12);
       break;
     case 3: // AI's left
       mStudent.stopAnimation(8);
       break;
     default:
       break;
   }
 }
Ejemplo n.º 3
0
  public boolean checkCollidesWithStudent(Student mStudent) {
    float studentX = mStudent.getX();
    float studentY = mStudent.getY();
    float AIX = getX();
    float AIY = getY();

    if ((this.collidesWith(Level_1_Class_Scene.mStudent)) && !finishedCheckCollidesWithBlock) {
      if (studentX == AIX) {
        if (this.Direction == 2 && (studentY > AIY)) return true;
        if (this.Direction == 0 && (studentY < AIY)) return true;
        return false;
      }
      if (studentY == AIY) {
        if (this.Direction == 1 && (studentX > AIX)) return true;
        if (this.Direction == 3 && (studentX < AIX)) return true;
        return false;
      }
      if ((studentX == AIX) && (studentY == AIY)) return true;
      return false;
    }
    return false;
  }