Exemplo n.º 1
0
  @Override
  protected Scene onCreateScene() {
    this.mScene = new Scene();
    this.xCoords = new float[COLUMNS];
    this.yCoords = new float[ROWS];
    float space =
        Math.min((float) CAMERA_HEIGHT / (float) ROWS, (float) CAMERA_WIDTH / (float) COLUMNS);
    float xCord = (CAMERA_WIDTH - space * (COLUMNS - 1)) / 2f;
    float yCord = (CAMERA_HEIGHT - space * (ROWS - 1)) / 2f;
    this.maps = new GomokuTiledSprite[COLUMNS - 1][ROWS - 1];
    VertexBufferObjectManager VBOManager = this.getVertexBufferObjectManager();
    Log.w("SPACE", "" + space);

    for (int i = 0; i < COLUMNS; i++) {
      xCoords[i] = xCord + i * space;
    }

    for (int i = 0; i < ROWS; i++) {
      yCoords[i] = yCord + i * space;
    }

    for (int i = 0; i < COLUMNS; i++) {
      Line line =
          new Line(xCoords[i], yCoords[0], xCoords[i], yCoords[ROWS - 1], STROKE_WIDTH, VBOManager);
      line.setColor(0f, 1f, 1f);
      mScene.attachChild(line);
    }

    for (int i = 0; i < ROWS; i++) {
      Line line =
          new Line(
              xCoords[0], yCoords[i], xCoords[COLUMNS - 1], yCoords[i], STROKE_WIDTH, VBOManager);
      line.setColor(0f, 1f, 1f);
      mScene.attachChild(line);
    }

    mScene.setTouchAreaBindingOnActionDownEnabled(true);
    mScene.setTouchAreaBindingOnActionMoveEnabled(false);

    for (int i = 0; i < COLUMNS - 1; i++) {
      for (int j = 0; j < ROWS - 1; j++) {
        this.maps[i][j] =
            new GomokuTiledSprite(
                xCoords[i] + space / 2f,
                yCoords[j] + space / 2f,
                blankRegion,
                xRegion,
                oRegion,
                winRegion,
                VBOManager,
                this);
        mScene.registerTouchArea(maps[i][j]);
        mScene.attachChild(maps[i][j]);
        maps[i][j].setCoordinates(i, j);
      }
    }

    return mScene;
  }
  @Override
  public Scene onCreateScene() {
    this.mEngine.registerUpdateHandler(new FPSLogger());

    this.mScene = new Scene();

    this.mScene.setOnAreaTouchTraversalFrontToBack();

    Rectangle easyRect =
        new Rectangle(
            FIRST_SPACE,
            FIRST_SPACE + TOP_BORDER,
            CAMERA_WIDTH * (1 - (2 * BORDER_SIZE)),
            (CAMERA_WIDTH * (1 - (2 * BORDER_SIZE))),
            this.getVertexBufferObjectManager());
    easyRect.setColor(1, 1, 1);

    this.mScene.setBackground(new Background(0.09804f, 0.6274f, 0.8784f));

    mScene.attachChild(easyRect);

    ;
    float pos_at = FIRST_SPACE;
    for (int i = 0; i <= NUM_ROWSCOLS; i++) {
      Line boardLineVert =
          new Line(
              pos_at,
              FIRST_SPACE + TOP_BORDER,
              pos_at,
              (CAMERA_WIDTH * (1 - BORDER_SIZE)) + TOP_BORDER,
              this.getVertexBufferObjectManager());
      Line boardLineHorz =
          new Line(
              FIRST_SPACE,
              pos_at + TOP_BORDER,
              CAMERA_WIDTH * (1 - BORDER_SIZE),
              pos_at + TOP_BORDER,
              this.getVertexBufferObjectManager());
      boardLineVert.setColor(0, 0, 0);
      boardLineHorz.setColor(0, 0, 0);
      mScene.attachChild(boardLineHorz);
      mScene.attachChild(boardLineVert);
      pos_at = pos_at + SPACING;
    }

    hudLoader.addTouchToScene(mScene, mZoomCamera);

    this.mScene.setTouchAreaBindingOnActionDownEnabled(true);

    return this.mScene;
  }
  @Override
  public Scene onCreateScene() {
    this.mEngine.registerUpdateHandler(new FPSLogger());

    final Scene scene = new Scene();
    scene.setBackground(new Background(0.09804f, 0.6274f, 0.8784f));

    final VertexBufferObjectManager vertexBufferObjectManager = this.getVertexBufferObjectManager();
    this.mText =
        new Text(
            50,
            40,
            this.mFont,
            "",
            1000,
            new TextOptions(true, AUTOWRAP_WIDTH, Text.LEADING_DEFAULT, HorizontalAlign.CENTER),
            vertexBufferObjectManager);
    scene.attachChild(this.mText);

    this.mLeft =
        new Line(0, 0, 0, TextBreakExample.CAMERA_HEIGHT, this.getVertexBufferObjectManager());
    this.mRight =
        new Line(0, 0, 0, TextBreakExample.CAMERA_HEIGHT, this.getVertexBufferObjectManager());

    this.mText.attachChild(this.mLeft);
    this.mText.attachChild(this.mRight);

    final Line leftBreakLine =
        new Line(0, 0, 0, TextBreakExample.CAMERA_HEIGHT, this.getVertexBufferObjectManager());
    leftBreakLine.setLineWidth(2);
    leftBreakLine.setColor(Color.RED);
    this.mText.attachChild(leftBreakLine);
    final Line rightBreakLine =
        new Line(
            AUTOWRAP_WIDTH,
            0,
            AUTOWRAP_WIDTH,
            TextBreakExample.CAMERA_HEIGHT,
            this.getVertexBufferObjectManager());
    rightBreakLine.setLineWidth(2);
    rightBreakLine.setColor(Color.RED);
    this.mText.attachChild(rightBreakLine);

    this.updateText();

    return scene;
  }
Exemplo n.º 4
0
  @Override
  public boolean onSceneTouchEvent(final Scene pScene, final TouchEvent pSceneTouchEvent) {
    final VertexBufferObjectManager vertexBufferObjectManager =
        activity.getVertexBufferObjectManager();
    // FixtureDef objectFixtureDef = PhysicsFactory.createFixtureDef(0.0f,
    //       0.0f, 0.0f);

    // centerText.detachSelf();

    if (linesDrawn <= 150) {
      if (pSceneTouchEvent.getAction() == TouchEvent.ACTION_DOWN) {
        isDrawing = true;
        i = 0;
      }
      if (pSceneTouchEvent.getAction() == TouchEvent.ACTION_UP) {
        isDrawing = false;
      }
      if (isDrawing = true) {
        rec[i] =
            new Rectangle(
                pSceneTouchEvent.getX(), pSceneTouchEvent.getY(), 1, 1, vertexBufferObjectManager);
        if (i != 0) {
          Line l =
              new Line(rec[i - 1].getX(), rec[i - 1].getY(), rec[i].getX(), rec[i].getY(), null);
          Line bodyLine =
              new Line(rec[i - 1].getX(), rec[i - 1].getY(), rec[i].getX(), rec[i].getY(), null);
          Body lb;
          Line line =
              new Line(rec[i - 1].getX(), rec[i - 1].getY(), rec[i].getX(), rec[i].getY(), null);
          lb = PhysicsFactory.createLineBody(mPhysicsWorld, bodyLine, wallFixtureDef);
          lb.setUserData("line");
          line.setLineWidth(5);
          bodyLine.setVisible(false);
          line.setColor(Color.WHITE);
          bodyLine.setColor(Color.WHITE);
          attachChild(bodyLine);
          attachChild(line);
          linesDrawn++;
          rectangle(linesDrawn);
        }
        linesDrawn++;
        i++;

        // final Text elapsedText = new Text(500, 360, activity.mFont, "Seconds elapsed:", "Seconds
        // elapsed: XXXXX".length(), activity.getVertexBufferObjectManager());
        // final Text fpsText = new Text(500, 400, activity.mFont, "FPS:", "FPS: XXXXX".length(),
        // activity.getVertexBufferObjectManager());

        // attachChild(elapsedText);
        // attachChild(fpsText);

        // final FPSCounter fpsCounter = new FPSCounter();

        //	registerUpdateHandler(new TimerHandler(1 / 20.0f, true, new ITimerCallback() {
        //		@Override
        //		public void onTimePassed(final TimerHandler pTimerHandler) {
        //			elapsedText.setText("Globs Used: " + linesDrawn);
        // fpsText.setText("Globs Left: " + ( 150 - linesDrawn));
        //		}
        //	}));
        //  }

      }
    }
    return true;
  }
Exemplo n.º 5
0
  public Level21() {

    setBackground(new Background(0, 0, 0));
    setOnSceneTouchListener(this);
    activity = World1Activity.getSharedInstance();
    Camera mCamera = activity.mCamera;
    Level1.mPhysicsWorld = new PhysicsWorld(new Vector2(0, SensorManager.GRAVITY_EARTH), false);
    mPhysicsWorld = Level1.mPhysicsWorld;
    Sprite bg = new Sprite(0, 0, activity.menuBgTexture6, activity.getVertexBufferObjectManager());
    setBackground(new SpriteBackground(bg));
    // activity.gameToast("The bugs have morphed and can travel through lines");
    // PhysicsWorld bPhysicsWorld = new PhysicsWorld(new Vector2(0,
    // SensorManager.GRAVITY_THE_ISLAND), false);
    final VertexBufferObjectManager vertexBufferObjectManager =
        activity.getVertexBufferObjectManager();
    final Rectangle ground =
        new Rectangle(0, mCamera.getHeight() - 2, mCamera.getWidth(), 2, vertexBufferObjectManager);
    final Rectangle roof = new Rectangle(0, 0, mCamera.getWidth(), 2, vertexBufferObjectManager);
    final Rectangle left = new Rectangle(0, 0, 2, mCamera.getHeight(), vertexBufferObjectManager);
    final Rectangle right =
        new Rectangle(mCamera.getWidth() - 2, 0, 2, mCamera.getHeight(), vertexBufferObjectManager);
    final Rectangle reset = new Rectangle(0, 0, 200, 20, vertexBufferObjectManager);

    ground.setColor(0, 255, 255);
    // right.setColor(Color.RED);

    //	final FixtureDef wallFixtureDef = PhysicsFactory.createFixtureDef(0, 0.5f, 0.5f, false,
    // CATEGORYBIT_WALL, MASKBITS_WALL, (short)0);
    Body Ground =
        PhysicsFactory.createBoxBody(mPhysicsWorld, ground, BodyType.StaticBody, WALL_FIXTURE_DEF);
    Body Roof =
        PhysicsFactory.createBoxBody(mPhysicsWorld, roof, BodyType.StaticBody, WALL_FIXTURE_DEF);
    Body Left =
        PhysicsFactory.createBoxBody(mPhysicsWorld, left, BodyType.StaticBody, WALL_FIXTURE_DEF);
    Body Right =
        PhysicsFactory.createBoxBody(mPhysicsWorld, right, BodyType.StaticBody, WALL_FIXTURE_DEF);
    Body Reset =
        PhysicsFactory.createBoxBody(mPhysicsWorld, reset, BodyType.StaticBody, WALL_FIXTURE_DEF);

    Ground.setUserData("ground");
    Roof.setUserData("roof");
    Left.setUserData("left");
    Right.setUserData("right");
    Reset.setUserData("tw");

    attachChild(ground);
    attachChild(roof);
    attachChild(left);
    attachChild(right);

    Rectangle help = new Rectangle(50, 220, 250, 10, vertexBufferObjectManager);
    Body Help =
        PhysicsFactory.createBoxBody(mPhysicsWorld, help, BodyType.StaticBody, WALL_FIXTURE_DEF);
    final Rectangle help2 = new Rectangle(0, 220, 50, 10, vertexBufferObjectManager);
    final Body Help2 =
        PhysicsFactory.createBoxBody(mPhysicsWorld, help2, BodyType.StaticBody, WALL_FIXTURE_DEF);
    Help2.setUserData("help");
    help2.setColor(Color.WHITE);
    attachChild(help2);
    Rectangle block = new Rectangle(180, 220, 250, 10, vertexBufferObjectManager);
    block.setRotation(90);

    Body Block =
        PhysicsFactory.createBoxBody(mPhysicsWorld, block, BodyType.StaticBody, WALL_FIXTURE_DEF);

    Block.setUserData("block");
    Help.setUserData("help");
    block.setColor(Color.WHITE);
    help.setColor(Color.WHITE);
    attachChild(help);
    attachChild(block);

    //	 final FixtureDef objectFixtureDef2 = PhysicsFactory.createFixtureDef(10, 0.2f, 0.5f,false,
    // CATEGORYBIT_WALL, MASKBITS_WALL, (short)0);

    final Text elapsedText =
        new Text(
            600, 10, activity.mFont3, "Score:0123456789", activity.getVertexBufferObjectManager());
    registerUpdateHandler(
        new TimerHandler(
            1 / 10f,
            true,
            new ITimerCallback() {
              @Override
              public void onTimePassed(final TimerHandler pTimerHandler) {

                if (score > 2501) {
                  score = (score - Math.round(activity.mCurrentScene.getSecondsElapsedTotal()));
                  elapsedText.setText("Score:" + score);
                } else {
                  score = 2500;
                  elapsedText.setText("Score:" + score);
                }
              }
            }));
    attachChild(elapsedText);

    final DelayModifier dMod =
        new DelayModifier(
            2,
            new IEntityModifierListener() {
              @Override
              public void onModifierStarted(IModifier arg0, IEntity arg1) {}

              public void onModifierFinished(IModifier arg0, IEntity arg1) {
                destroy(0);
              }
            });

    final Rectangle bL = new Rectangle(150, 365, 50, 20, vertexBufferObjectManager);
    final Rectangle bB = new Rectangle(125, 355, 50, 10, vertexBufferObjectManager);
    final Rectangle bR = new Rectangle(175, 355, 50, 10, vertexBufferObjectManager);
    final Rectangle finish = new Rectangle(150, 360, 50, 20, vertexBufferObjectManager);
    bR.setRotation(90);
    bB.setRotation(90);

    one = new Rectangle(765, 290, 25, 35, vertexBufferObjectManager);
    two = new Rectangle(765, 330, 25, 35, vertexBufferObjectManager);
    three = new Rectangle(765, 370, 25, 35, vertexBufferObjectManager);
    four = new Rectangle(765, 410, 25, 35, vertexBufferObjectManager);
    five = new Rectangle(765, 450, 25, 35, vertexBufferObjectManager);

    one.setColor(Color.GREEN);
    two.setColor(Color.GREEN);
    three.setColor(Color.YELLOW);
    four.setColor(Color.YELLOW);
    five.setColor(Color.RED);

    attachChild(one);
    attachChild(two);
    attachChild(three);
    attachChild(four);
    attachChild(five);

    Rectangle laser = new Rectangle(350, 200, 20, 20, vertexBufferObjectManager);
    laser.setColor(Color.RED);
    attachChild(laser);
    final Line lase = new Line(350, 205, 805, 200, 5, vertexBufferObjectManager);
    final Body Lase = PhysicsFactory.createLineBody(mPhysicsWorld, lase, WALL_FIXTURE_DEF);
    Lase.setUserData("laser");
    lase.setColor(Color.RED);
    lase.setVisible(false);
    Lase.setActive(false);
    attachChild(lase);

    registerUpdateHandler(
        new IUpdateHandler() {
          @Override
          public void onUpdate(float pSecondsElapsed) {
            x = x + 1;
            if (x == 50) {
              lase.setVisible(true);
              Lase.setActive(true);
            } else if (x == 100) {
              lase.setVisible(false);
              Lase.setActive(false);
              x = 0;
            }
          }

          @Override
          public void reset() {
            // TODO Auto-generated method stub

          }
        });

    final Rectangle powerup = new Rectangle(665, 050, 15, 15, vertexBufferObjectManager);
    powerup.setColor(Color.RED);
    final Body power =
        PhysicsFactory.createBoxBody(mPhysicsWorld, powerup, BodyType.StaticBody, WALL_FIXTURE_DEF);
    powerup.setVisible(true);
    power.setActive(true);

    Body bod =
        PhysicsFactory.createBoxBody(mPhysicsWorld, bL, BodyType.StaticBody, WALL_FIXTURE_DEF);
    Body lbod =
        PhysicsFactory.createBoxBody(mPhysicsWorld, bR, BodyType.StaticBody, WALL_FIXTURE_DEF);
    Body rbod =
        PhysicsFactory.createBoxBody(mPhysicsWorld, bB, BodyType.StaticBody, WALL_FIXTURE_DEF);
    Body Finish =
        PhysicsFactory.createBoxBody(
            mPhysicsWorld, finish, BodyType.StaticBody, CIRCLE_FIXTURE_DEF);

    // Rectangle help = new Rectangle(0, 220, 300, 10, vertexBufferObjectManager);
    // Body Help = PhysicsFactory.createBoxBody(mPhysicsWorld, help, BodyType.StaticBody,
    // wallFixtureDef);

    // Rectangle block = new Rectangle(180, 220, 250, 10, vertexBufferObjectManager);
    // block.setRotation(90);

    // Body Block = PhysicsFactory.createBoxBody(mPhysicsWorld, block, BodyType.StaticBody,
    // wallFixtureDef);

    // Block.setUserData("block");
    bod.setUserData("body");
    rbod.setUserData("body");
    lbod.setUserData("body");
    Finish.setUserData("finish");
    power.setUserData("power");
    //	Help.setUserData("Help");
    bL.setColor(Color.WHITE);
    //	block.setColor(255, 0, 0);
    bR.setColor(Color.WHITE);
    bB.setColor(Color.WHITE);
    //	help.setColor(255, 0, 0);
    finish.setColor(0, 0, 1);
    finish.setVisible(false);

    //	attachChild(block);
    attachChild(bL);
    attachChild(bR);
    attachChild(bB);
    // attachChild(help);
    attachChild(finish);
    attachChild(powerup);

    // centerText = new Text(320, 40, activity.mFont, "IMPORTANT!!! Keep an eye \n out for powerups
    // \n to help you through \n the level \n (touch anywhere to make \n this message dissapear)",
    // new TextOptions(HorizontalAlign.CENTER), vertexBufferObjectManager);
    // attachChild(centerText);
    // final ButtonSprite button = new ButtonSprite(5, 5, activity.mMenuResetTextureRegion,
    // vertexBufferObjectManager);
    // attachChild(button);

    final int blue = activity.faceSelected(1);

    if (blue == 1)
      face = new AnimatedSprite(05, 150, activity.redFace, activity.getVertexBufferObjectManager());
    else if (blue == 2)
      face =
          new AnimatedSprite(05, 150, activity.blueFace, activity.getVertexBufferObjectManager());
    else if (blue == 3)
      face =
          new AnimatedSprite(05, 150, activity.yellowFace, activity.getVertexBufferObjectManager());
    else if (blue == 4)
      face =
          new AnimatedSprite(05, 150, activity.hairFace, activity.getVertexBufferObjectManager());
    else if (blue == 5)
      face = new AnimatedSprite(05, 150, activity.djFace, activity.getVertexBufferObjectManager());
    else if (blue == 6)
      face = new AnimatedSprite(05, 150, activity.jetFace, activity.getVertexBufferObjectManager());
    else if (blue == 7)
      face =
          new AnimatedSprite(05, 150, activity.slowFace, activity.getVertexBufferObjectManager());
    else if (blue == 8)
      face =
          new AnimatedSprite(05, 150, activity.fastFace, activity.getVertexBufferObjectManager());
    else
      face = new AnimatedSprite(05, 150, activity.redFace, activity.getVertexBufferObjectManager());

    body =
        PhysicsFactory.createCircleBody(
            mPhysicsWorld, face, BodyType.DynamicBody, FACE_FIXTURE_DEF);

    body.setUserData("face");
    face.animate(200);

    attachChild(face);
    mPhysicsWorld.registerPhysicsConnector(new PhysicsConnector(face, body, true, true));
    registerUpdateHandler(mPhysicsWorld);
    Random r = new Random();
    int i = r.nextInt(4 - 1) + 1;
    if (i == 1) {
      enemy = new Sprite(400, 200, activity.bug2, activity.getVertexBufferObjectManager());
      enemy2 = new Sprite(400, 200, activity.bug3, activity.getVertexBufferObjectManager());
      enemy3 = new Sprite(400, 200, activity.bug1, activity.getVertexBufferObjectManager());
    } else if (i == 2) {
      enemy = new Sprite(400, 200, activity.bug2, activity.getVertexBufferObjectManager());
      enemy2 = new Sprite(400, 200, activity.bug1, activity.getVertexBufferObjectManager());
      enemy3 = new Sprite(400, 200, activity.bug2, activity.getVertexBufferObjectManager());
    } else if (i == 3) {
      enemy = new Sprite(400, 200, activity.bug3, activity.getVertexBufferObjectManager());
      enemy2 = new Sprite(400, 200, activity.bug2, activity.getVertexBufferObjectManager());
      enemy3 = new Sprite(400, 200, activity.bug3, activity.getVertexBufferObjectManager());
    } else enemy = new Sprite(400, 200, activity.bug1, activity.getVertexBufferObjectManager());
    enemy2 = new Sprite(400, 200, activity.bug2, activity.getVertexBufferObjectManager());
    enemy3 = new Sprite(400, 200, activity.bug3, activity.getVertexBufferObjectManager());

    // final Rectangle enemy = new Rectangle(600,400, 15, 15,
    // activity.getVertexBufferObjectManager());
    Enemy =
        PhysicsFactory.createBoxBody(
            mPhysicsWorld, enemy, BodyType.DynamicBody, CIRCLE_FIXTURE_DEF);
    Enemy.setUserData("enemy");
    attachChild(enemy);
    mPhysicsWorld.registerPhysicsConnector(new PhysicsConnector(enemy, Enemy, true, true));

    // final Rectangle enemy2 = new Rectangle(500,400, 15, 15,
    // activity.getVertexBufferObjectManager());
    Enemy2 =
        PhysicsFactory.createBoxBody(
            mPhysicsWorld, enemy2, BodyType.DynamicBody, CIRCLE_FIXTURE_DEF);
    Enemy2.setUserData("enemy");
    attachChild(enemy2);
    mPhysicsWorld.registerPhysicsConnector(new PhysicsConnector(enemy2, Enemy2, true, true));

    //	final Rectangle enemy3 = new Rectangle(400,400, 15, 15,
    // activity.getVertexBufferObjectManager());
    Enemy3 =
        PhysicsFactory.createBoxBody(
            mPhysicsWorld, enemy3, BodyType.DynamicBody, CIRCLE_FIXTURE_DEF);
    Enemy3.setUserData("enemy");
    attachChild(enemy3);
    mPhysicsWorld.registerPhysicsConnector(new PhysicsConnector(enemy3, Enemy3, true, true));
    // Enemy.setLinearVelocity(10, -10);

    /*final AnimatedSprite windArea = new AnimatedSprite(200, 0, 50, 500, activity.mBoxFaceTextureRegion, activity.getVertexBufferObjectManager())
        {
            @Override
            protected void onManagedUpdate(float pSecondsElapsed)
            {
                if (face.collidesWith(this))
                {
                    body.applyLinearImpulse(new Vector2(0, -10f), body.getWorldCenter());
                }
            };
        };
      //  windArea.setVisible(false);
        attachChild(windArea);

    */

    Rectangle pauseBtn =
        new Rectangle(10, 10, 100, 100, activity.getVertexBufferObjectManager()) {
          @Override
          public boolean onAreaTouched(
              TouchEvent pSceneTouchEvent, float pTouchAreaLocalX, float pTouchAreaLocalY) {
            if (pSceneTouchEvent.getAction() == MotionEvent.ACTION_UP) {

              Scene menu = (activity.createMenuScene());
              activity.menu = 21;
              setChildScene(menu, false, true, true);
            }
            return true;
          }
        };

    pauseBtn.setVisible(false);
    // pauseBtn.setColor(0,0,1);
    attachChild(pauseBtn);
    registerTouchArea(pauseBtn);

    final Text resetText =
        new Text(
            10,
            10,
            activity.mFont3,
            "Pause",
            new TextOptions(HorizontalAlign.CENTER),
            vertexBufferObjectManager);
    attachChild(resetText);

    mPhysicsWorld.setContactListener(
        new ContactListener() {
          @Override
          public void beginContact(final Contact contact) {

            final Fixture A = contact.getFixtureA();
            final Fixture B = contact.getFixtureB();

            final Body bodyA = A.getBody();
            final Body bodyB = B.getBody();

            String abe = bodyA.getUserData().toString();
            String be = bodyB.getUserData().toString();

            if (abe == "left" || be == "left") {

              Enemy.applyLinearImpulse(new Vector2(1, 0.5f), body.getWorldCenter());
              Enemy2.applyLinearImpulse(new Vector2(1, 0.5f), body.getWorldCenter());
              Enemy3.applyLinearImpulse(new Vector2(1, 0.5f), body.getWorldCenter());
            } else if (abe == "power" && be != "enemy") {

              l = -5;
              activity.gameToast("Nice super shield active. Resetting line....");
              linesDrawn = 0;
              rectangle(linesDrawn);
              powerup.setVisible(false);
              power.setActive(false);
              help2.setVisible(false);
              Help2.setActive(false);
            }

            if (abe == "finish" && be == "face") {
              bB.setColor(0, 0, 1);
              bL.setColor(0, 0, 1);
              bR.setColor(0, 0, 1);
              // lase.setVisible(false);
              // Lase.setActive(false);
              // x = 500;

              registerEntityModifier(dMod);
            }

            if (abe == "laser" && be == "face") {

              if (l >= 0) {
                l = l + 1;
                activity.gameToast("Shield only blocks one laser hit-Hit #" + l);

                if (l == 2) destroy(1);
              } else if (l < 0) {
                activity.gameToast("Super Shield active");
                l = l + 1;
              }
            } else if (abe == "roof" || be == "roof") {
              Enemy.applyLinearImpulse(new Vector2(0.5f, 1f), body.getWorldCenter());
              Enemy2.applyLinearImpulse(new Vector2(0.5f, 1f), body.getWorldCenter());
              Enemy3.applyLinearImpulse(new Vector2(0.5f, 1f), body.getWorldCenter());
            } else if (abe == "right" || be == "right") {
              Enemy.applyLinearImpulse(new Vector2(-1, 0.5f), body.getWorldCenter());
              Enemy2.applyLinearImpulse(new Vector2(-1, 0.5f), body.getWorldCenter());
              Enemy3.applyLinearImpulse(new Vector2(-1, 0.5f), body.getWorldCenter());
            } else if (abe == "ground" || be == "ground") {
              Enemy.applyLinearImpulse(new Vector2(0.5f, -2f), body.getWorldCenter());
              Enemy2.applyLinearImpulse(new Vector2(0.5f, -2f), body.getWorldCenter());
              Enemy3.applyLinearImpulse(new Vector2(0.5f, -2f), body.getWorldCenter());
            } else if (abe == "enemy" && be == "face") {

              if (l >= 0) {
                l = l + 1;
                activity.gameToast("Hit #" + l);
                if (l == 3) destroy(1);
              } else if (l < 0) {

                if (dead == 0) {
                  enemy.setVisible(false);
                  Enemy.setActive(false);
                  dead = dead + 1;
                  l = l + 1;
                  activity.gameToast("Enemy eleminated");
                } else if (dead == 1) {
                  enemy2.setVisible(false);
                  Enemy2.setActive(false);
                  l = l + 1;
                  dead = dead + 1;
                  activity.gameToast("Enemy 2 eleminated");
                } else if (l == -3) {
                  enemy3.setVisible(false);
                  Enemy3.setActive(false);
                  l = l + 1;
                  dead = dead + 1;
                  activity.gameToast("Enemy 3 eleminated");
                } else {
                  l = l + 1;
                }
              }
            }
          }

          @Override
          public void endContact(final Contact pContact) {}

          @Override
          public void preSolve(Contact contact, Manifold oldManifold) {}

          @Override
          public void postSolve(Contact contact, ContactImpulse impulse) {}
        });
  }
Exemplo n.º 6
0
 private Line createLine(int i) {
   int y = 260 - i * 50;
   final Line line = new Line(250, y, 540, y, vertexBufferObjectManager);
   line.setColor(Color.BLACK);
   return line;
 }
  private void init(KeyListenScene pBaseScene) {
    // 共通ウィンドウを作成
    CommonWindowRectangle comonWindowRectangle =
        new CommonWindowRectangle(
            0,
            0,
            pBaseScene.getWindowWidth(),
            pBaseScene.getWindowHeight(),
            Color.BLACK,
            0.8f,
            pBaseScene);
    attachChild(comonWindowRectangle);
    // タイトル
    float titleY = 12;
    Font titleFont = pBaseScene.createFont(Typeface.DEFAULT_BOLD, 30, Color.WHITE);
    Text titleText =
        new Text(
            10,
            10,
            titleFont,
            "〜 経験値振り分け 〜",
            pBaseScene.getBaseActivity().getVertexBufferObjectManager());
    pBaseScene.placeToCenterX(titleText, titleY);
    attachChild(titleText);

    float titleLineY = titleText.getY() + titleText.getHeight() + 4;

    Line line =
        new Line(
            10,
            titleLineY,
            pBaseScene.getWindowWidth() - 16,
            titleLineY,
            pBaseScene.getBaseActivity().getVertexBufferObjectManager());
    line.setLineWidth(1);
    line.setColor(Color.WHITE);
    line.setAlpha(1.0f);
    attachChild(line);

    TextLogic textLogic = new TextLogic();
    Font defaultFont = pBaseScene.createFont(Typeface.SANS_SERIF, 16, Color.WHITE);
    Font paramFont = pBaseScene.createFont(Typeface.DEFAULT, 16, Color.YELLOW);
    // Font upParamFont = pBaseScene.createFont(Typeface.DEFAULT, 16, Color.BLUE);
    // Expの表示
    float expY = titleLineY + 4;
    Rectangle totalExpTextRect =
        textLogic.createTextRectangle(
            "所持経験値:",
            defaultFont,
            "100 Exp",
            paramFont,
            pBaseScene.getBaseActivity().getVertexBufferObjectManager());
    attachChild(totalExpTextRect);

    Rectangle afterExpTextRect =
        textLogic.createTextRectangle(
            "振り分け後経験値:",
            defaultFont,
            "0 Exp",
            paramFont,
            pBaseScene.getBaseActivity().getVertexBufferObjectManager());
    attachChild(afterExpTextRect);

    totalExpTextRect.setPosition(
        pBaseScene.getWindowWidth() / 2
            - (totalExpTextRect.getX()
                    + totalExpTextRect.getWidth()
                    + 50
                    + afterExpTextRect.getWidth())
                / 2,
        expY);

    afterExpTextRect.setPosition(
        totalExpTextRect.getX() + totalExpTextRect.getWidth() + 50, totalExpTextRect.getY());

    float expLineY = totalExpTextRect.getY() + totalExpTextRect.getHeight() + 4;
    Line expLine =
        new Line(
            10,
            expLineY,
            pBaseScene.getWindowWidth() - 16,
            expLineY,
            pBaseScene.getBaseActivity().getVertexBufferObjectManager());
    expLine.setLineWidth(1);
    expLine.setColor(Color.WHITE);
    expLine.setAlpha(1.0f);
    attachChild(expLine);

    // プレイヤー情報
    float playerX = 12;
    float playerY = expLineY + 12;

    ActorPlayerLogic actorPlayerLogic = new ActorPlayerLogic();
    ActorPlayerDto actorPlayerDto = actorPlayerLogic.createActorPlayerDto(pBaseScene, 1);

    PlayerStatusRectangle playerStatusRectangle =
        new PlayerStatusRectangle(
            pBaseScene,
            defaultFont,
            actorPlayerDto,
            ActorSpriteUtil.getFaceFileName(actorPlayerDto.getImageResId()),
            playerX,
            playerY);
    playerStatusRectangle.show(PlayerStatusRectangleType.MINI_STATUS);
    attachChild(playerStatusRectangle);
  }
Exemplo n.º 8
0
  private void addFieldLines(
      final Color borderColor, final Color gridColor, final int borderWidth, final int gridWidth) {
    // Remove old lines if there were any before
    for (Line line : this.gameFieldLines) {
      line.detachSelf();
      line.dispose();
    }
    this.gameFieldLines.clear();

    // add vertical lines
    for (int cellX = 1; cellX < this.getModel().getWidth(); cellX++) {
      Line line =
          new Line(
              cellX * GameField.CELL_WIDTH,
              0,
              cellX * GameField.CELL_WIDTH,
              this.getHeight(),
              this.vertexBufferObjectManager);
      line.setColor(gridColor);
      line.setLineWidth(gridWidth);
      this.gameFieldLines.add(line);
      this.attachChild(line);
    }

    // add horizontal lines
    for (int cellY = 1; cellY < this.getModel().getHeight(); cellY++) {
      Line line =
          new Line(
              0,
              cellY * GameField.CELL_HEIGHT,
              this.getWidth(),
              cellY * GameField.CELL_HEIGHT,
              this.vertexBufferObjectManager);
      line.setColor(gridColor);
      line.setLineWidth(gridWidth);
      this.gameFieldLines.add(line);
      this.attachChild(line);
    }

    // Adding border for the game-field
    Line firstLineVertical = new Line(0, 0, 0, this.getHeight(), this.vertexBufferObjectManager);
    firstLineVertical.setColor(borderColor);
    firstLineVertical.setLineWidth(borderWidth);
    this.gameFieldLines.add(firstLineVertical);
    this.attachChild(firstLineVertical);
    Line lastLineVertical =
        new Line(
            this.getModel().getWidth() * GameField.CELL_WIDTH,
            0,
            this.getModel().getWidth() * GameField.CELL_WIDTH,
            this.getHeight(),
            this.vertexBufferObjectManager);
    lastLineVertical.setColor(borderColor);
    lastLineVertical.setLineWidth(borderWidth);
    this.gameFieldLines.add(lastLineVertical);
    this.attachChild(lastLineVertical);
    Line firstLineHorizontal = new Line(0, 0, this.getWidth(), 0, this.vertexBufferObjectManager);
    firstLineHorizontal.setColor(borderColor);
    firstLineHorizontal.setLineWidth(borderWidth);
    this.gameFieldLines.add(firstLineHorizontal);
    this.attachChild(firstLineHorizontal);
    Line lastLineHorizontal =
        new Line(
            0,
            this.getModel().getHeight() * GameField.CELL_HEIGHT,
            this.getWidth(),
            this.getModel().getHeight() * GameField.CELL_HEIGHT,
            this.vertexBufferObjectManager);
    lastLineHorizontal.setColor(borderColor);
    lastLineHorizontal.setLineWidth(borderWidth);
    this.gameFieldLines.add(lastLineHorizontal);
    this.attachChild(lastLineHorizontal);
  }