Esempio 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);
  }
Esempio n. 2
0
 public void addanimationItem(
     final float x,
     final float y,
     final AnimatedItemPool animationItemPool,
     final Student
         mStudent) { // them vao hieu ung trai tim khi nguoi va cham vao chuong ngai vat di dong
   final AnimatedItem animationItem = animationItemPool.obtainPoolItem();
   animationItem.setPosition(x, y);
   // x : cot ----------------------
   // y : hang ---------------------
   if (animationItem.isAttachToScene() == false) {
     LevelManager.getScene().attachChild(animationItem);
     animationItem.setAttachToScene(true);
   }
   animationItem.animate(
       (long)
           (TIME_STUN
               * 1000
               / loopCountanimationItem
               / animationItem.getTextureRegion().getTileCount()),
       loopCountanimationItem,
       new IAnimationListener() {
         @Override
         public void onAnimationEnd(final AnimatedSprite pAnimatedSprite) {
           LevelManager.getEngine()
               .runOnUpdateThread(
                   new Runnable() {
                     @Override
                     public void run() {
                       animationItemPool.recyclePoolItem(animationItem);
                       mStudent.registerListener();
                       mStudent.setTouchEnable(true);
                       registerListener();
                     }
                   });
         }
       });
 }