Exemplo n.º 1
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());
                  }
                });
          }
        });
  }
Exemplo n.º 2
0
  public Sprite getMenuBackground() {
    mMenuBackgroundRegion =
        BitmapTextureAtlasTextureRegionFactory.createFromAsset(
            mBuildableBitmapTextureAtlas, Game.getContext(), "menuback.png");
    try {
      mBuildableBitmapTextureAtlas.build(
          new BlackPawnTextureAtlasBuilder<IBitmapTextureAtlasSource, BitmapTextureAtlas>(0, 0, 1));
      mBuildableBitmapTextureAtlas.load();
    } catch (TextureAtlasBuilderException e) {
      e.printStackTrace();
    }
    mMenuBackgroundSprite =
        new Sprite(0, 0, mMenuBackgroundRegion, Game.getContext().getVertexBufferObjectManager());
    mMenuBackgroundSprite.setBlendFunction(GLES20.GL_SRC_ALPHA, GLES20.GL_ONE_MINUS_SRC_ALPHA);
    mMenuBackgroundSprite.setAlpha(0.2f);

    return mMenuBackgroundSprite;
  }
Exemplo n.º 3
0
  public TiledImage(
      float pX,
      float pY,
      float pWidth,
      float pHeight,
      ITextureRegion pTextureRegion,
      VertexBufferObjectManager vertexBufferObjectManager,
      int voice,
      Context cont) {
    super(pX, pY, pWidth, pHeight, pTextureRegion, vertexBufferObjectManager);
    con = cont;
    ObjNo++;
    audioPlayCount = 0;
    audio = voice;
    audioPlay = false;
    mediaPlayer = new MediaPlayer();
    this.Letter =
        new Sprite(pX, pY, pTextureRegion, vertexBufferObjectManager) {
          @Override
          public boolean onAreaTouched(
              final TouchEvent pSceneTouchEvent,
              final float pTouchAreaLocalX,
              final float pTouchAreaLocalY) {
            switch (pSceneTouchEvent.getAction()) {
              case TouchEvent.ACTION_DOWN:
                {
                  this.setScale(1.09f);
                  break;
                }
              case TouchEvent.ACTION_MOVE:
                {
                  break;
                }
              case TouchEvent.ACTION_UP:
                {
                  this.setScale(1.0f);
                  audioPlay = true;
                  playAudio(audio);
                  break;
                }
              default:
                {
                }
            }
            return false;
          }
        };
    en = new Entity(0, 0);
    s = new Sprite(-20, -20, AnimatedBookActivity.SpriteBgTextureRegion, vertexBufferObjectManager);
    Letter.setWidth(pHeight - 40);
    Letter.setHeight(pHeight - 40);
    // s.setPosition(pX - 30, pY - 30);
    s.setWidth(pHeight + 10);
    s.setHeight(pHeight + 10);
    s.setZIndex(-1);
    s.setAlpha(0.8f);

    Letter.attachChild(s);

    s.setVisible(false);
    Letter.setVisible(false);

    AnimateImage();
  }
  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++;
    }
  }
  @Override
  public Scene onCreateScene() {
    this.mEngine.registerUpdateHandler(new FPSLogger());

    final Scene scene = new Scene();
    scene.getBackground().setColor(0.09804f, 0.6274f, 0.8784f);

    final int centerX = CAMERA_WIDTH / 2;
    final int centerY = CAMERA_HEIGHT / 2;

    final Sprite sprite =
        new Sprite(centerX, centerY, this.mFaceTextureRegion, this.getVertexBufferObjectManager());
    final PhysicsHandler physicsHandler = new PhysicsHandler(sprite);
    sprite.registerUpdateHandler(physicsHandler);

    scene.attachChild(sprite);

    /* Velocity control (left). */
    final AnalogOnScreenControl velocityOnScreenControl =
        new AnalogOnScreenControl(
            0,
            0,
            this.mCamera,
            this.mOnScreenControlBaseTextureRegion,
            this.mOnScreenControlKnobTextureRegion,
            0.1f,
            this.getVertexBufferObjectManager(),
            new IAnalogOnScreenControlListener() {
              @Override
              public void onControlChange(
                  final BaseOnScreenControl pBaseOnScreenControl,
                  final float pValueX,
                  final float pValueY) {
                physicsHandler.setVelocity(pValueX * 100, pValueY * 100);
              }

              @Override
              public void onControlClick(final AnalogOnScreenControl pAnalogOnScreenControl) {
                /* Nothing. */
              }
            });

    {
      final Sprite controlBase = velocityOnScreenControl.getControlBase();
      controlBase.setAlpha(0.5f);
      controlBase.setOffsetCenter(0, 0);

      scene.setChildScene(velocityOnScreenControl);
    }

    /* Rotation control (right). */
    final float y = (this.mPlaceOnScreenControlsAtDifferentVerticalLocations) ? CAMERA_HEIGHT : 0;
    final AnalogOnScreenControl rotationOnScreenControl =
        new AnalogOnScreenControl(
            CAMERA_WIDTH,
            y,
            this.mCamera,
            this.mOnScreenControlBaseTextureRegion,
            this.mOnScreenControlKnobTextureRegion,
            0.1f,
            this.getVertexBufferObjectManager(),
            new IAnalogOnScreenControlListener() {
              @Override
              public void onControlChange(
                  final BaseOnScreenControl pBaseOnScreenControl,
                  final float pValueX,
                  final float pValueY) {
                if (pValueX == 0 && pValueY == 0) {
                  sprite.setRotation(0);
                } else {
                  sprite.setRotation(MathUtils.radToDeg((float) Math.atan2(pValueX, pValueY)));
                }
              }

              @Override
              public void onControlClick(final AnalogOnScreenControl pAnalogOnScreenControl) {
                /* Nothing. */
              }
            });

    {
      final Sprite controlBase = rotationOnScreenControl.getControlBase();
      if (this.mPlaceOnScreenControlsAtDifferentVerticalLocations) {
        controlBase.setOffsetCenter(1, 1);
      } else {
        controlBase.setOffsetCenter(1, 0);
      }
      controlBase.setAlpha(0.5f);

      velocityOnScreenControl.setChildScene(rotationOnScreenControl);
    }

    return scene;
  }