private void drawUsingSpriteBatch(final Scene pScene) {
    final IEntityModifier faceEntityModifier =
        new SequenceEntityModifier(
            new RotationByModifier(2, 90),
            new AlphaModifier(1.5f, 1, 0),
            new AlphaModifier(1.5f, 0, 1),
            new ScaleModifier(2.5f, 1, 0.5f),
            new DelayModifier(0.5f),
            new ParallelEntityModifier(
                new ScaleModifier(2f, 0.5f, 5), new RotationByModifier(2, 90)),
            new ParallelEntityModifier(
                new ScaleModifier(2f, 5, 1), new RotationModifier(2f, 180, 0)));

    final VertexBufferObjectManager vertexBufferObjectManager = this.getVertexBufferObjectManager();
    final SpriteGroup spriteGroup =
        new SpriteGroup(
            this.mFaceTexture, EntityModifierBenchmark.SPRITE_COUNT, vertexBufferObjectManager);
    spriteGroup.setBlendFunction(GLES20.GL_SRC_ALPHA, GLES20.GL_ONE_MINUS_SRC_ALPHA);

    for (int i = 0; i < EntityModifierBenchmark.SPRITE_COUNT; i++) {
      final Sprite face =
          new Sprite(
              (EntityModifierBenchmark.CAMERA_WIDTH - 32) * this.mRandom.nextFloat(),
              (EntityModifierBenchmark.CAMERA_HEIGHT - 32) * this.mRandom.nextFloat(),
              this.mFaceTextureRegion,
              vertexBufferObjectManager);
      face.registerEntityModifier(faceEntityModifier.deepCopy());

      spriteGroup.attachChild(face);
    }

    pScene.attachChild(spriteGroup);
  }
Ejemplo n.º 2
0
  public void addTarget() {
    Random rand = new Random();

    int minX = 0;
    int maxX = (int) (mCamera.getWidth() - activity.enemySprite.getWidth());
    int rangeX = maxX - minX;
    int y = (int) -activity.enemySprite.getHeight();
    int x = rand.nextInt(rangeX) - minX;

    Sprite target = new Sprite(x, y, activity.enemyRegion, activity.getVertexBufferObjectManager());
    target.setSize(
        activity.mCamera.getWidth() / 10.8f * 1.5f, activity.mCamera.getWidth() / 10.8f * 1.5f);

    target.setZIndex(3);

    attachChild(target);

    int minDuration = 3;
    int maxDuration = 6;
    int rangeDuration = maxDuration - minDuration;
    int actualDuration = rand.nextInt(rangeDuration) + minDuration;
    int actualMoveX = rand.nextInt((int) (mCamera.getWidth() - target.getWidth()));

    MoveModifier mod =
        new MoveModifier(
            actualDuration,
            target.getX(),
            actualMoveX,
            target.getY(),
            mCamera.getHeight() + target.getHeight());

    target.registerEntityModifier(mod.deepCopy());

    enemiesToBeAdded.add(target);
  }
  private void effectRate(Rate mRate) {
    // Log.e(tag, "effectRate");

    Sprite sprite = fastSprite;

    switch (mRate) {
      case FAST:
        sprite = new Sprite(0, 0, Region.fast, vbom);
        break;
      case SUPER_FAST:
        sprite = new Sprite(0, 0, Region.superFast, vbom);
        break;
      case COMPLETE:
        sprite = new Sprite(0, 0, Region.complete, vbom);
        break;
      case WRONG:
        sprite = new Sprite(0, 0, Region.wrong, vbom);
        break;
      case SLOW:
        sprite = new Sprite(0, 0, Region.slow, vbom);
        break;
    }

    setToCenter(sprite);
    sprite.setScale(0);
    attachChild(sprite);

    sprite.registerEntityModifier(
        new SequenceEntityModifier(
            new ScaleAtModifier(0.2f, 0, 1, sprite.getWidth() / 2, sprite.getHeight() / 2),
            new AlphaModifier(0.3f, 1, 1),
            new AlphaModifier(0.1f, 1, 0)));
  }
Ejemplo n.º 4
0
 private void spawnCar(final float screenWidth, final float screenHeight) {
   lane = r.nextInt(6) + 1;
   final Sprite car = new Sprite(-300, 0, carTR, this.activity.getVertexBufferObjectManager());
   car.setRotation(180);
   MoveModifier moveModifier =
       new MoveModifier(
           4,
           lane * GameManager.lengthOfTile,
           lane * GameManager.lengthOfTile,
           -GameManager.lengthOfTile * 2,
           screenHeight + GameManager.lengthOfTile * 2) {
         @Override
         protected void onModifierFinished(IEntity pItem) {
           super.onModifierFinished(pItem);
           lane = r.nextInt(6) + 1;
           this.reset(
               4,
               lane * GameManager.lengthOfTile,
               lane * GameManager.lengthOfTile,
               -GameManager.lengthOfTile * 2,
               screenHeight + GameManager.lengthOfTile * 2);
         }
       };
   car.registerEntityModifier(moveModifier);
   menuScene.attachChild(car);
 }
  private void drawUsingSpritesWithSharedVertexBuffer(final Scene pScene) {
    final IEntityModifier faceEntityModifier =
        new SequenceEntityModifier(
            new RotationByModifier(2, 90),
            new AlphaModifier(1.5f, 1, 0),
            new AlphaModifier(1.5f, 0, 1),
            new ScaleModifier(2.5f, 1, 0.5f),
            new DelayModifier(0.5f),
            new ParallelEntityModifier(
                new ScaleModifier(2f, 0.5f, 5), new RotationByModifier(2, 90)),
            new ParallelEntityModifier(
                new ScaleModifier(2f, 5, 1), new RotationModifier(2f, 180, 0)));

    /* As we are creating quite a lot of the same Sprites, we can let them share a VertexBuffer to significantly increase performance. */
    final ISpriteVertexBufferObject sharedVertexBuffer =
        new LowMemorySpriteVertexBufferObject(
            this.getVertexBufferObjectManager(),
            Sprite.SPRITE_SIZE,
            DrawType.STATIC,
            true,
            Sprite.VERTEXBUFFEROBJECTATTRIBUTES_DEFAULT);

    for (int i = 0; i < SPRITE_COUNT; i++) {
      final Sprite face =
          new Sprite(
              (CAMERA_WIDTH - 32) * this.mRandom.nextFloat(),
              (CAMERA_HEIGHT - 32) * this.mRandom.nextFloat(),
              this.mFaceTextureRegion,
              sharedVertexBuffer);
      face.setBlendFunction(GLES20.GL_SRC_ALPHA, GLES20.GL_ONE_MINUS_SRC_ALPHA);
      face.registerEntityModifier(faceEntityModifier.deepCopy());

      pScene.attachChild(face);
    }
  }
Ejemplo n.º 6
0
  void AnimateImage() {
    Log.d("TiledImage", "ObjNo: " + ObjNo);
    if (ObjNo == 2) {
      anotherDelay = 10.0f;
      // anotherCounter=1;
    } else if (ObjNo == 3) {
      anotherDelay = 12.1f;
      // anotherCounter=1;
    } else if (ObjNo == 4) {
      anotherDelay = 14.1f;
      // anotherCounter=1;
    } else if (ObjNo == 5) {
      anotherDelay = 16.1f;
      // anotherCounter=1;
    } else if (ObjNo == 6) {
      anotherDelay = 18.1f;
      // anotherCounter=1;
    } else if (ObjNo == 7) {
      anotherDelay = 20.1f;
      // anotherCounter=1;
    } else {
      anotherDelay = 22.3f;
    }
    Log.d(
        "TiledImage",
        "ObjNo: " + ObjNo + " anotherDelay: " + anotherDelay + " total: " + ObjNo * anotherDelay);

    DelayModifier dMod =
        new DelayModifier(
            anotherDelay,
            new IEntityModifierListener() {
              @Override
              public void onModifierStarted(IModifier<IEntity> arg0, IEntity arg1) {}

              @Override
              public void onModifierFinished(IModifier<IEntity> arg0, IEntity arg1) {
                Letter.setVisible(true);
                s.setVisible(true);

                audioPlay = true;
                playAudio(audio);

                audioPlayCount++;
                if (audioPlayCount == 6) {
                  audioPlay = true;
                  AnimatedBookActivity.ArrowTouchEnable = true;
                  // ObjNo=0;
                }
              }
            });
    FadeInModifier macch_fim2 = new FadeInModifier(APPEARING_TIME);
    SequenceEntityModifier macch_sm = new SequenceEntityModifier(dMod, macch_fim2);

    Letter.registerEntityModifier(macch_sm);
  }
  private void effectReadyGo() {
    // Log.e(tag, "effectReadyGo");

    this.attachChild(readySprite);
    setToCenter(readySprite);
    readySprite.setScale(0);

    this.attachChild(goSprite);
    setToCenter(goSprite);
    goSprite.setScale(0);

    readySprite.registerEntityModifier(
        new SequenceEntityModifier(
            new ScaleAtModifier(
                0.7f, 0, 1, readySprite.getWidth() / 2, readySprite.getHeight() / 2),
            new AlphaModifier(0.75f, 1, 1),
            new AlphaModifier(0.3f, 1, 0)));

    goSprite.registerEntityModifier(
        new SequenceEntityModifier(
            new ScaleAtModifier(1.7f, 0, 0, goSprite.getWidth() / 2, goSprite.getHeight() / 2),
            new ScaleAtModifier(0.7f, 0, 1, goSprite.getWidth() / 2, goSprite.getHeight() / 2),
            new AlphaModifier(0.75f, 1, 1),
            new AlphaModifier(
                0.3f,
                1,
                0,
                new IEntityModifier.IEntityModifierListener() {
                  @Override
                  public void onModifierStarted(
                      IModifier<IEntity> iEntityIModifier, IEntity iEntity) {}

                  @Override
                  public void onModifierFinished(
                      IModifier<IEntity> iEntityIModifier, IEntity iEntity) {
                    // Log.e(tag, "onModifierFinished");
                    initTime();
                    taskInit();
                  }
                })));
  }
Ejemplo n.º 8
0
 public void checkArrow() {
   if (CUBIC_SLOT[0] == false || CUBIC_SLOT[1] == false) {
     mArrowSprite.setVisible(true);
     mArrowSprite.clearEntityModifiers();
     mArrowSprite.registerEntityModifier(
         new LoopEntityModifier(
             new SequenceEntityModifier(
                 new AlphaModifier(0.5f, 0.2f, 1.0f), new AlphaModifier(0.5f, 1.0f, 0.2f))));
   } else {
     mArrowSprite.setVisible(false);
     mArrowSprite.clearEntityModifiers();
   }
 }
Ejemplo n.º 9
0
    public CubicEntity(
        float pX,
        float pY,
        int pCubic,
        final ITiledTextureRegion pCubicStart,
        final ITiledTextureRegion pCubicTurn,
        final ITiledTextureRegion pCubicStop,
        final ITiledTextureRegion pCubicTurnOption[],
        ITextureRegion pTextureRegion) {
      super(pX, pY, pTextureRegion, mVertexBufferObjectManager);
      setAlpha(0.0f);
      TYPE = pCubic;
      mCubicStartAniSprite = new AnimatedSprite(0, 0, pCubicStart, mVertexBufferObjectManager);
      this.attachChild(mCubicStartAniSprite);
      mCubicStartAniSprite.setVisible(false);

      float turnX = getWidth() - pCubicTurn.getWidth();
      float turnY = getHeight() - pCubicTurn.getHeight();
      mCubicTurnAniSprite =
          new AnimatedSprite(turnX - 15, turnY - 15, pCubicTurn, mVertexBufferObjectManager);
      this.attachChild(mCubicTurnAniSprite);
      mCubicTurnAniSprite.setVisible(false);

      for (int i = 0; i < mCubicTurnOptionAniSprite.length; i++) {
        float turnOpX = getWidth() - pCubicTurnOption[i].getWidth();
        float turnOpY = getHeight() - pCubicTurnOption[i].getHeight();
        mCubicTurnOptionAniSprite[i] =
            new AnimatedSprite(turnOpX, turnOpY, pCubicTurnOption[i], mVertexBufferObjectManager);
        this.attachChild(mCubicTurnOptionAniSprite[i]);
        mCubicTurnOptionAniSprite[i].setVisible(false);
      }

      float stopX = getWidth() - pCubicTurn.getWidth();
      float stopY = getHeight() - pCubicTurn.getHeight();
      mCubicStopAniSprite =
          new AnimatedSprite(stopX - 15, stopY - 15, pCubicStop, mVertexBufferObjectManager);
      this.attachChild(mCubicStopAniSprite);
      mCubicStopAniSprite.setVisible(false);

      float scrollX = turnX + pCubicTurn.getWidth() / 2 - mScrollLeftTextureRegion.getWidth();
      float scrollY = turnY + pCubicTurn.getHeight() - mScrollLeftTextureRegion.getHeight();
      mScrollLeftSprite =
          new Sprite(scrollX, scrollY, mScrollLeftTextureRegion, mVertexBufferObjectManager);
      this.attachChild(mScrollLeftSprite);
      mScrollLeftSprite.setVisible(false);

      mScrollLeftSprite.registerEntityModifier(
          new LoopEntityModifier(
              new SequenceEntityModifier(
                  new AlphaModifier(0.5f, 0.2f, 1.0f), new AlphaModifier(0.5f, 1.0f, 0.2f))));
    }
  public void buttonClick(int position) {
    if (buttonsNumber == 2) {
      buttons2[position].onClick();
      Sprite pointer =
          new Sprite(
              buttons2[position].getX() + 50,
              buttons2[position].getY() + 40,
              VideoScene.Regions.pointer,
              vbom);
      pointer.registerEntityModifier(new AlphaModifier(0.2f, 1, 0));
      attachChild(pointer);

    } else if (buttonsNumber == 3) {
      buttons3[position].onClick();
      Sprite pointer =
          new Sprite(
              buttons3[position].getX() + 50,
              buttons3[position].getY() + 40,
              VideoScene.Regions.pointer,
              vbom);
      pointer.registerEntityModifier(new AlphaModifier(0.2f, 1, 0));
      attachChild(pointer);
    }
  }
Ejemplo n.º 11
0
  private void babyCry() {
    isBabyCry = false;
    A19_9B_5_NAKIGOE1.play();
    mFingerAnimatedSprite[4].animate(new long[] {500, 300}, new int[] {6, 7}, 0);
    mMilkSprite.showAction();

    this.mScene.registerUpdateHandler(
        new TimerHandler(
            0.5f,
            new ITimerCallback() {

              @Override
              public void onTimePassed(TimerHandler pTimerHandler) {
                mCryLeftSprite.setVisible(true);
                mCryRightSprite.setVisible(true);
                mCryLeftSprite.setAlpha(1.0f);
                mCryRightSprite.setAlpha(1.0f);
              }
            }));

    final LoopEntityModifier loop = new LoopEntityModifier(new AlphaModifier(1.0f, 1.0f, 0.0f));
    mCryLeftSprite.registerEntityModifier(loop);
    mCryRightSprite.registerEntityModifier(loop.deepCopy());
  }
Ejemplo n.º 12
0
  public SplashScene() {
    setBackground(new Background(0.f, 0f, .0f));
    activity = CamaleaotestActivity.getSharedInstance();

    mSplash = new Sprite(117, 177, activity.mSplashScreen, activity.getVertexBufferObjectManager());
    mSplash.setAlpha(0);
    this.attachChild(mSplash);
    mSplash.registerEntityModifier(
        new SequenceEntityModifier(
            new FadeInModifier(2) {
              @Override
              protected void onModifierFinished(IEntity pItem) {
                activity.loadAssets();
                super.onModifierFinished(pItem);
              }
            },
            new DelayModifier(5f) {
              @Override
              protected void onModifierFinished(IEntity pItem) {
                // TODO Auto-generated method stub
                super.onModifierFinished(pItem);
                mReady = true;
              }
            }));

    this.registerUpdateHandler(
        new IUpdateHandler() {
          @Override
          public void reset() {
            // TODO Auto-generated method stub

          }

          @Override
          public void onUpdate(float pSecondsElapsed) {
            if (activity.loading || !mReady) return;
            mSplash.registerEntityModifier(
                new FadeOutModifier(2f) {
                  @Override
                  protected void onModifierFinished(IEntity pItem) {
                    // TODO Auto-generated method stub
                    super.onModifierFinished(pItem);
                    activity.setCurrentScene(new MainMenuScene());
                  }
                });
          }
        });
  }
  public void effectMiss(int mPosition) {

    int[] x = {50, 150, 250};

    // Sprite sprite = new Sprite(0, 0, Region.miss, vbom);
    Sprite sprite = getMissFromPool();
    // if (sprite.getParent() != this) {
    this.attachChild(sprite);
    // }
    setToCenter(sprite);
    sprite.setX(x[mPosition]);

    sprite.registerEntityModifier(
        new SequenceEntityModifier(
            new ScaleAtModifier(0.3f, 0, 1, sprite.getWidth() / 2, sprite.getHeight() / 2),
            new AlphaModifier(0.3f, 1, 1),
            new AlphaModifier(0.3f, 1, 0)));
  }
Ejemplo n.º 14
0
  @Override
  public void onResumeGame() {
    for (int i = 0; i < mCubicChooseSpite.length; i++) {
      mCubicChooseSpite[i].setVisible(true);
    }
    CUBIC_SLOT[0] = false;
    CUBIC_SLOT[1] = false;
    this.unregisterUpdateHandler(updateHandler);
    this.registerUpdateHandler(
        updateHandler =
            new IUpdateHandler() {

              @Override
              public void reset() {}

              @Override
              public void onUpdate(float f) {
                for (int i = 0; i < mCubicEntity.length; i++) {
                  if (mCubicEntity[i].isVisible()
                      && mCubicEntity[i].getCubicAction() >= CubicEntity.ACTION_TURN_LEVEL_1
                      && mCubicEntity[i].getCubicAction() <= CubicEntity.ACTION_TURN_FUNGI
                      && mShishiAniSprite.isVisible() == true
                      && mShishiAniSprite.collidesWith(mCubicEntity[i].getCubicBody())) {
                    Log.i(TAG, i + " va cham voi shishi ");
                    Vol3Osyougatsu.OGG_A3_A_6_GO.play();
                    Vol3Osyougatsu.OGG_A3_A_6_KACHIN.play();
                    mCubicEntity[i].stopTurn();
                  }
                }
              }
            });
    mArrowSprite.setVisible(true);
    mArrowSprite.clearEntityModifiers();
    mArrowSprite.registerEntityModifier(
        new LoopEntityModifier(
            new SequenceEntityModifier(
                new AlphaModifier(0.5f, 0.2f, 1.0f), new AlphaModifier(0.5f, 1.0f, 0.2f))));
    Log.i(TAG, "-- onResumeGame --");
  }
Ejemplo n.º 15
0
 public void newEvent(float pX, float pY, int pSlot) {
   mCubicChooseSpite[TYPE].setVisible(false);
   SLOT = pSlot;
   CUBIC_SLOT[SLOT] = true;
   checkArrow();
   this.setPosition(0, 100);
   ACTION = ACTION_DEFAULT;
   mCubicStartAniSprite.setVisible(true);
   mScrollLeftSprite.clearEntityModifiers();
   mScrollLeftSprite.registerEntityModifier(
       new LoopEntityModifier(
           new SequenceEntityModifier(
               new AlphaModifier(0.5f, 0.2f, 1.0f), new AlphaModifier(0.5f, 1.0f, 0.2f))));
   mScrollLeftSprite.setVisible(true);
   this.setVisible(true);
   final Body body = (Body) CubicEntity.this.getUserData();
   Vector2 vector2 =
       Vector2Pool.obtain(
           pX / PhysicsConstants.PIXEL_TO_METER_RATIO_DEFAULT,
           pY / PhysicsConstants.PIXEL_TO_METER_RATIO_DEFAULT);
   body.setTransform(vector2, 0);
   Vector2Pool.recycle(vector2);
 }
Ejemplo n.º 16
0
 private void changeButtonColor(HudButton button, Color color) {
   Sprite target = this.getTargetedButton(button);
   target.clearEntityModifiers();
   target.registerEntityModifier(new ColorModifier(0.2f, target.getColor(), color));
 }
Ejemplo n.º 17
0
  public org.andengine.entity.scene.menu.MenuScene createScene() {
    float screenWidth = camera.getWidth();
    float screenHeight = camera.getHeight();
    menuScene = new org.andengine.entity.scene.menu.MenuScene(camera);

    // BACKGROUND SETUP
    map.loadMap(menuScene);
    // menuScene.attachChild(map.createScene(10));

    spawnCar(screenWidth, screenHeight);

    // BANNER/LOGO & banner animation
    final Sprite banner =
        new Sprite(
            (screenWidth - dodgecarsTR.getWidth()) / 2,
            (screenHeight / 7) / 2,
            dodgecarsTR,
            this.activity.getVertexBufferObjectManager());
    rotBan = false;
    scaBan = false;
    banner.registerEntityModifier(
        new ScaleModifier(scaleDuration, startScale, endScale) {
          @Override
          protected void onModifierFinished(IEntity pItem) {
            super.onModifierFinished(pItem);
            if (scaBan) {
              this.reset(scaleDuration, startScale, endScale, startScale, endScale);
              scaBan = !scaBan;
            } else {
              this.reset(scaleDuration, endScale, startScale, endScale, startScale);
              scaBan = !scaBan;
            }
          }
        });
    banner.registerEntityModifier(
        new RotationModifier(rotDuration, startRot, endRot) {
          @Override
          protected void onModifierFinished(IEntity pItem) {
            super.onModifierFinished(pItem);
            if (!rotBan) {
              this.reset(rotDuration, endRot, startRot);
              rotBan = !rotBan;
            } else {
              this.reset(rotDuration, startRot, endRot);
              rotBan = !rotBan;
            }
          }
        });

    // MENU ITEMS
    final IMenuItem buttonPlay =
        new ScaleMenuItemDecorator(
            new SpriteMenuItem(PLAY_BTN_ID, playTR, this.activity.getVertexBufferObjectManager()),
            unSelected,
            onSelected);
    final IMenuItem buttonHighScore =
        new ScaleMenuItemDecorator(
            new SpriteMenuItem(
                HIGHSCORE_BTN_ID, highscoreTR, this.activity.getVertexBufferObjectManager()),
            unSelected,
            onSelected);
    final IMenuItem buttonCredits =
        new ScaleMenuItemDecorator(
            new SpriteMenuItem(
                CREDITS_BTN_ID, creditsTR, this.activity.getVertexBufferObjectManager()),
            unSelected,
            onSelected);
    buttonPlay.setPosition((screenWidth - playTR.getWidth()) / 2, screenHeight / 7 * 3);
    buttonHighScore.setPosition((screenWidth - highscoreTR.getWidth()) / 2, screenHeight / 7 * 4);
    buttonCredits.setPosition((screenWidth - creditsTR.getWidth()) / 2, screenHeight / 7 * 5);

    // Sound and Music on/off buttons
    soundOnBtn =
        new Sprite(
            camera.getWidth() - soundsOnTR.getWidth() * 2,
            0,
            soundsOnTR,
            this.activity.getVertexBufferObjectManager());
    soundOffBtn =
        new Sprite(
            camera.getWidth() - soundsOnTR.getWidth() * 2,
            0,
            soundsOffTR,
            this.activity.getVertexBufferObjectManager());
    musicOnBtn =
        new Sprite(
            camera.getWidth() - musicOnTR.getWidth(),
            0,
            musicOnTR,
            this.activity.getVertexBufferObjectManager());
    musicOffBtn =
        new Sprite(
            camera.getWidth() - musicOnTR.getWidth(),
            0,
            musicOffTR,
            this.activity.getVertexBufferObjectManager());

    menuScene.attachChild(banner);
    menuScene.addMenuItem(buttonPlay);
    menuScene.addMenuItem(buttonHighScore);
    menuScene.addMenuItem(buttonCredits);

    if (sounds.playMusic) {
      menuScene.attachChild(musicOffBtn);
      menuScene.attachChild(musicOnBtn);
      musicOffBtn.setVisible(false);
      musicOnBtn.setVisible(true);
    } else {
      menuScene.attachChild(musicOnBtn);
      menuScene.attachChild(musicOffBtn);
      musicOnBtn.setVisible(false);
      musicOffBtn.setVisible(true);
    }

    if (sounds.playSounds) {
      menuScene.attachChild(soundOffBtn);
      menuScene.attachChild(soundOnBtn);
      soundOffBtn.setVisible(false);
      soundOnBtn.setVisible(true);
    } else {
      menuScene.attachChild(soundOnBtn);
      menuScene.attachChild(soundOffBtn);
      soundOnBtn.setVisible(false);
      soundOffBtn.setVisible(true);
    }

    final Rectangle soundRec =
        new Rectangle(
            camera.getWidth() - soundsOnTR.getWidth() * 2,
            0,
            GameManager.lengthOfTile,
            GameManager.lengthOfTile,
            this.activity.getVertexBufferObjectManager()) {
          public boolean onAreaTouched(TouchEvent touchEvent, float X, float Y) {
            if (touchEvent.isActionDown()) {
              if (sounds.playSounds) {
                sounds.setSoundsEnable(false);
                soundOnBtn.setVisible(false);
                soundOffBtn.setVisible(true);
              } else {
                sounds.setSoundsEnable(true);
                soundOffBtn.setVisible(false);
                soundOnBtn.setVisible(true);
              }
            }
            return true;
          };
        };
    final Rectangle musicRec =
        new Rectangle(
            camera.getWidth() - musicOnTR.getWidth(),
            0,
            GameManager.lengthOfTile,
            GameManager.lengthOfTile,
            this.activity.getVertexBufferObjectManager()) {
          public boolean onAreaTouched(TouchEvent touchEvent, float X, float Y) {
            if (touchEvent.isActionDown()) {
              if (sounds.playMusic) {
                sounds.setMusicEnable(false);
                sounds.pauseMusic();
                musicOnBtn.setVisible(false);
                musicOffBtn.setVisible(true);
              } else {
                sounds.setMusicEnable(true);
                sounds.playMusic();
                musicOffBtn.setVisible(false);
                musicOnBtn.setVisible(true);
              }
            }
            return true;
          };
        };
    soundRec.setAlpha(255);
    musicRec.setAlpha(255);
    menuScene.registerTouchArea(soundRec);
    menuScene.registerTouchArea(musicRec);
    menuScene.attachChild(soundRec);
    menuScene.attachChild(musicRec);

    menuScene.setOnMenuItemClickListener(
        new IOnMenuItemClickListener() {
          @Override
          public boolean onMenuItemClicked(
              org.andengine.entity.scene.menu.MenuScene pMenuScene,
              IMenuItem pMenuItem,
              float pMenuItemLocalX,
              float pMenuItemLocalY) {

            switch (pMenuItem.getID()) {
              case PLAY_BTN_ID:
                sounds.playCarStart();
                sceneManager.createGameScene();
                sceneManager.setCurrentSence(AllScenes.GAME);
                break;
              case HIGHSCORE_BTN_ID:
                sounds.playBlop();
                sceneManager.createHighScoreScene();
                sceneManager.setCurrentSence(AllScenes.HIGHSCORE);
                break;
              case CREDITS_BTN_ID:
                sounds.playBlop();
                sceneManager.createCreditScene();
                sceneManager.setCurrentSence(AllScenes.CREDITS);
                break;
            }

            return false;
          }
        });

    return menuScene;
  }
  public void showPowerupIcon(Powerup powerup) {

    Sprite icon = null;
    final float ANIMATION_DELTA_Y = 96f;

    ITextureRegion iconTextureRegion = null;

    switch (powerup.getId()) {
      case Powerups.ID_SPEED_BOOST:
        iconTextureRegion = HudRegions.region_boost_icon;
        break;

      default:
        Log.e("Mortal Showdown", powerup.getId() + " is an invalid power-up id!");
        break;
    }

    if (iconTextureRegion != null)
      icon =
          new Sprite(
              16f * this.powerupIconCount,
              20,
              iconTextureRegion,
              EnvironmentVars.MAIN_CONTEXT.getVertexBufferObjectManager());

    if (icon != null) {

      final DelayModifier[] ICON_DELAYS = new DelayModifier[2];

      ICON_DELAYS[0] = new DelayModifier(powerup.getDuration() * 0.8f);
      ICON_DELAYS[1] = new DelayModifier(powerup.getDuration() * 0.2f);

      final Sprite ICON = icon;

      // @formatter:off
      ICON_DELAYS[0].addModifierListener(
          new IModifierListener<IEntity>() {
            @Override
            public void onModifierFinished(IModifier<IEntity> pModifier, IEntity pItem) {
              EnvironmentVars.MAIN_CONTEXT.runOnUpdateThread(
                  new Runnable() {
                    @Override
                    public void run() {
                      ICON.registerEntityModifier(ICON_DELAYS[1]);
                    }
                  });
            }

            @Override
            public void onModifierStarted(IModifier<IEntity> pModifier, IEntity pItem) {}
          });
      ICON_DELAYS[0].setAutoUnregisterWhenFinished(true);
      ICON_DELAYS[1].addModifierListener(
          new IModifierListener<IEntity>() {

            final FlashUpdateHandler FLASH = new FlashUpdateHandler(0.2f, -1);

            @Override
            public void onModifierFinished(IModifier<IEntity> pModifier, IEntity pItem) {
              EnvironmentVars.MAIN_CONTEXT.runOnUpdateThread(
                  new Runnable() {
                    @Override
                    public void run() {
                      Inventory.this.powerupIconCount--;
                      ICON.unregisterUpdateHandler(FLASH);
                      ICON.detachSelf();
                      ICON.dispose();
                    }
                  });
            }

            @Override
            public void onModifierStarted(IModifier<IEntity> pModifier, IEntity pItem) {
              this.FLASH.runOnSwitch(
                  new Runnable() {
                    @Override
                    public void run() {
                      ICON.setVisible(!ICON.isVisible());
                    }
                  });
              ICON.registerUpdateHandler(this.FLASH);
            }
          });
      ICON_DELAYS[1].setAutoUnregisterWhenFinished(true);
      // @formatter:on

      // @formatter:off
      final ParallelEntityModifier ICON_MOD =
          new ParallelEntityModifier(
              new AlphaModifier(Inventory.POWERUP_ICON_ANIMATION_DURATION, 0f, 1f),
              new MoveYModifier(
                  Inventory.POWERUP_ICON_ANIMATION_DURATION,
                  icon.getY() + ANIMATION_DELTA_Y,
                  icon.getY(),
                  EaseCubicOut.getInstance()),
              ICON_DELAYS[0]);

      icon.setAlpha(0f);
      icon.setY(icon.getY() + ANIMATION_DELTA_Y);
      icon.registerEntityModifier(ICON_MOD);
      this.sAmmoIcon.attachChild(icon);
      // @formatter:on
      this.powerupIconCount++;
    }
  }
Ejemplo n.º 19
0
  private void clockAction() {
    isClock = false;
    A19_06_BO_NBOBO_N.play();

    mClockAnimatedSprite.animate(
        new long[] {550, 550},
        new int[] {2, 3},
        1,
        new IAnimationListener() {

          @Override
          public void onAnimationFinished(AnimatedSprite arg0) {
            mClockAnimatedSprite.animate(new long[] {500, 500}, new int[] {0, 1}, -1);
          }

          @Override
          public void onAnimationFrameChanged(AnimatedSprite arg0, int arg1, int arg2) {}

          @Override
          public void onAnimationLoopFinished(AnimatedSprite arg0, int arg1, int arg2) {}

          @Override
          public void onAnimationStarted(AnimatedSprite arg0, int arg1) {}
        });
    mClockCandyLeftSprite.setVisible(true);
    mClockCandyRightSprite.setVisible(true);

    mClockCandyLeftSprite.registerEntityModifier(
        new MoveModifier(1.2f, LpX, LpX - 20, LpY, LpY + 500));

    mClockCandyRightSprite.registerEntityModifier(
        new MoveModifier(
            1.2f,
            RpX,
            RpX + 20,
            RpY,
            RpY + 500,
            new IEntityModifierListener() {

              @Override
              public void onModifierFinished(IModifier<IEntity> pModifier, IEntity pItem) {
                runOnUpdateThread(
                    new Runnable() {

                      @Override
                      public void run() {

                        mClockCandyLeftSprite.clearEntityModifiers();
                        mClockCandyLeftSprite.setPosition(LpX, LpY);
                        mClockCandyLeftSprite.setVisible(false);

                        mClockCandyRightSprite.clearEntityModifiers();
                        mClockCandyLeftSprite.setPosition(RpX, RpY);
                        mClockCandyRightSprite.reset();
                        mClockCandyRightSprite.setVisible(false);
                        isClock = true;

                        Log.d("xxx", "" + mClockCandyLeftSprite.getY());
                      }
                    });
              }

              @Override
              public void onModifierStarted(IModifier<IEntity> arg0, IEntity arg1) {}
            }));
  }
  /**
   * BOSS滑块
   *
   * @author zuowhat 2013-11-25
   * @since 1.0
   */
  private Rectangle getScensSlider() {
    bossPics = new AnimatedButtonSprite[ResourceManager.mxdBoss_TTRArray.length];
    Sprite[] bossBlackBG = new Sprite[bossPics.length];
    // Sprite[] bossInfo = new Sprite[bossPics.length];
    float themeRWidth = mCameraWidth * bossPics.length;
    themeRInitX = themeRWidth / 2f;
    Rectangle themeR =
        new Rectangle(
            themeRWidth / 2f,
            mCameraHeight / 2f,
            themeRWidth,
            mCameraHeight * (2f / 3f),
            mVertexBufferObjectManager);
    themeR.setAlpha(0f);
    int themeSceneOneBossTotal =
        BangYouScreenActivity.getIntFromSharedPreferences(DataConstant.SHARED_PREFS_THEME_MXD);
    for (int i = 0; i < ResourceManager.mxdBoss_TTRArray.length; i++) {
      if (i < themeSceneOneBossTotal) {
        if (isKO) {
          if (i != (mCurrentBoss - 1)) {
            // KO标志
            Sprite s = new Sprite(0f, 0f, ResourceManager.ko, mVertexBufferObjectManager);
            EntityUtil.setSize("width", 1f / 4f, s);
            s.setPosition((i + 1f / 2f) * mCameraWidth, themeR.getHeight() / 2f);
            themeR.attachChild(s);
          } else {
            // KO动画
            Sprite s = new Sprite(0f, 0f, ResourceManager.ko, mVertexBufferObjectManager);
            EntityUtil.setSize("width", 1f / 4f, s);
            s.setPosition((i + 1f / 2f) * mCameraWidth, themeR.getHeight() / 2f);
            themeR.attachChild(s);
            ScaleAtModifier highestPicScale =
                new ScaleAtModifier(0.5f, 25f, 1f, 0.5f, 0.5f); // 实体缩放
            FadeInModifier highestPicFadeIn = new FadeInModifier(0.5f); // 在0.5秒内改变透明度由0f变为1f
            ParallelEntityModifier highestPicParalle =
                new ParallelEntityModifier(
                    new IEntityModifierListener() {

                      @Override
                      public void onModifierStarted(IModifier<IEntity> pModifier, IEntity pItem) {
                        SFXManager.getInstance().playSound("t_ko");
                      }

                      @Override
                      public void onModifierFinished(IModifier<IEntity> pModifier, IEntity pItem) {
                        // TODO Auto-generated method stub

                      }
                    },
                    highestPicScale,
                    highestPicFadeIn); // 同时执行修饰符
            s.registerEntityModifier(highestPicParalle);
          }
        } else {
          // KO标志
          Sprite s = new Sprite(0f, 0f, ResourceManager.ko, mVertexBufferObjectManager);
          EntityUtil.setSize("width", 1f / 4f, s);
          s.setPosition((i + 1f / 2f) * mCameraWidth, themeR.getHeight() / 2f);
          themeR.attachChild(s);
        }
      }
      if (ResourceManager.mxdBoss_TTRArray[i] != null) {

        // BOSS动画
        bossPics[i] =
            new AnimatedButtonSprite(
                0f, 0f, ResourceManager.mxdBoss_TTRArray[i], mVertexBufferObjectManager);
        EntityUtil.setSize("height", 1f / 2f, bossPics[i]);
        // BOSS简介
        // bossInfo[i] = new Sprite(0f, 0f,ResourceManager.mxdBoss_InfoTRArray[i],
        // mVertexBufferObjectManager);
        // EntityUtil.setSize("height", 1f/2f, bossInfo[i]);
        if (i == 0) {
          bossPics[i].setPosition(mCameraWidth / 4f, themeR.getHeight() / 2f);
          // bossInfo[i].setPosition(3f*mCameraWidth/4f, themeR.getHeight()/2f);
        }
        if (i == 7) {
          long[] frameDur = new long[2];
          Arrays.fill(frameDur, 300);
          bossPics[i].animate(frameDur, 0, 1, true);
        } else {
          bossPics[i].animate(100, true);
        }

        bossPics[i].setOnClickListenerABS(
            new OnClickListenerABS() {
              @Override
              public void onClick(
                  AnimatedButtonSprite pButtonSprite,
                  float pTouchAreaLocalX,
                  float pTouchAreaLocalY) {
                SFXManager.getInstance().playSound("a_click");
                SFXManager.getInstance().stopMusic();
                SceneManager.getInstance()
                    .showScene(
                        new GameLevel(
                            DataConstant.getMXDBoss(mCurrentBoss), DataConstant.getPlayerModel()));
              }
            });
        // BOSS图片和简介的位置
        if (i > 0) {
          bossPics[i].setPosition(mCameraWidth + bossPics[i - 1].getX(), themeR.getHeight() / 2f);
          // bossInfo[i].setPosition(mCameraWidth+bossInfo[i-1].getX(), themeR.getHeight()/2f);
        }
        themeR.attachChild(bossPics[i]);
        registerTouchArea(bossPics[i]);
        // themeR.attachChild(bossInfo[i]);
      } else {
        bossBlackBG[i] =
            new Sprite(
                0f,
                0f,
                ResourceManager.bossBlackBG.getTextureRegion(i),
                mVertexBufferObjectManager);
        EntityUtil.setSize("height", 1f / 2f, bossBlackBG[i]);
        bossBlackBG[i].setPosition(mCameraWidth * (i + 1f / 4f), themeR.getHeight() / 2f);

        switch (i) {
          case 0:
            break;

          case 1:
            break;
        }
        themeR.attachChild(bossBlackBG[i]);
      }
    }

    return themeR;
  }