Esempio n. 1
0
  public void jetfire() {
    GameScene scene = (GameScene) MainGameEngineActivity.getSharedInstance().mCurrentScene;

    pe = new PointParticleEmitter(this.getX(), this.getY());

    jps =
        new BatchedPseudoSpriteParticleSystem(
            pe, 8, 12, 200, ResourcesManager.getInstance().jetfire, scene.getVbom());
    jps.setBlendFunction(GLES20.GL_SRC_ALPHA, GLES20.GL_ONE);
    jps.addParticleInitializer(new VelocityParticleInitializer<Entity>(0, 0, 0, -25));
    jps.addParticleInitializer(new AccelerationParticleInitializer<Entity>(5, -11));
    jps.addParticleInitializer(new RotationParticleInitializer<Entity>(0.0f, 360.0f));
    jps.addParticleInitializer(new ColorParticleInitializer<Entity>(1.0f, 1.0f, 0.0f));
    jps.addParticleInitializer(new ExpireParticleInitializer<Entity>(.8f, 2f));

    jps.addParticleModifier(new ScaleParticleModifier<Entity>(0, 5, 2.5f, 2.0f));
    jps.addParticleModifier(
        new ColorParticleModifier<Entity>(1.5f, 2.5f, 1.0f, 2.0f, 1.0f, 1.0f, 0.0f, 1.0f));
    jps.addParticleModifier(new AlphaParticleModifier<Entity>(1.5f, 2.5f, 1.0f, 0.0f));

    scene.attachChild(jps);
    jps.setParticlesSpawnEnabled(false);

    // BOOLEAN TO USE FOR START STO EMITION

  }
Esempio n. 2
0
  public Player(
      float pX, float pY, VertexBufferObjectManager vbo, Camera camera, PhysicsWorld physicsWorld) {
    super(
        pX,
        pY,
        com.tesc.sos2014.managers.ResourcesManager.getInstance().player_region.deepCopy(),
        vbo);
    createPhysics(camera, physicsWorld);
    camera.setChaseEntity(this);

    // jetfire();
  }
Esempio n. 3
0
  private void createPhysics(final Camera camera, PhysicsWorld physicsWorld) {
    body =
        PhysicsFactory.createBoxBody(
            physicsWorld, this, BodyType.DynamicBody, PhysicsFactory.createFixtureDef(0, 0, 0));
    as =
        new AnimatedSprite(
            mHeight,
            mHeight,
            ResourcesManager.getInstance().player_region.deepCopy(),
            MainGameEngineActivity.getSharedInstance()
                .getSharedInstance()
                .getVertexBufferObjectManager());

    body.setUserData(as);
    body.setFixedRotation(true);

    physicsWorld.registerPhysicsConnector(
        new PhysicsConnector(this, body, true, false) {
          @Override
          public void onUpdate(float pSecondsElapsed) {
            super.onUpdate(pSecondsElapsed);
            camera.onUpdate(0.1f);

            if (jetfireCalled == false) {
              jetfire();
              jetfireCalled = true;
              jumpTimer = fuelLevel;
            }
            if (getY() <= 0) {
              onDie();
            }

            if (jumping) {

              jumpTimer--;

              if (jumpTimer >= 1) {

                GameScene scene =
                    (GameScene) MainGameEngineActivity.getSharedInstance().mCurrentScene;

                scene.fuelText.setText(("Fuel: " + jumpTimer));
                if (jumpTimer > fuelLevel / 2) {
                  scene.fuelText.setColor(Color.rgb(0, 255, 0));
                } else if (jumpTimer > fuelLevel / 3 && jumpTimer < fuelLevel / 2) {
                  scene.fuelText.setColor(Color.rgb(255, 255, 0));
                } else {
                  scene.fuelText.setColor(Color.rgb(255, 0, 0));
                }

                body.setLinearVelocity(new Vector2(body.getLinearVelocity().x, 4));
                pe.setCenter(getX(), getY());

              } else if (jumpTimer <= 0) {
                GameScene scene =
                    (GameScene) MainGameEngineActivity.getSharedInstance().mCurrentScene;

                scene.fuelText.setText(("Fuel:Charging"));
                jumpRecharge--;
                pe.setCenter(-1000, -1000);
              }
              if (jumpRecharge <= 0 && jumpTimer <= 0) {
                pe.setCenter(-1000, -1000);
                jumpRecharge = 75;
                jumpTimer = fuelLevel;
              }
            }

            if (right) {
              body.setLinearVelocity(new Vector2(5, body.getLinearVelocity().y));
            }
            if (left) {
              body.setLinearVelocity(new Vector2(-5, body.getLinearVelocity().y));
            }

            if (stop) {
              body.setLinearVelocity(new Vector2(0, body.getLinearVelocity().y));
            }
          }
        });
  }