Ejemplo n.º 1
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))));
    }
  protected void createInvSprite(ITiledTextureRegion sheet) {

    final float w = this.getWidth();
    final float h = this.getHeight();
    final float sw = sheet.getWidth();
    final float sh = sheet.getHeight();

    this.sInvSprite =
        new TiledSprite(
            (w - sw) / 2f,
            (h - sh) / 2f,
            sheet,
            EnvironmentVars.MAIN_CONTEXT.getVertexBufferObjectManager());
    this.sInvSprite.setRotationCenter(sw / 2f, sh / 2f);
    this.sInvSprite.setRotation(Inventory.INVENTORY_ICON_ROTATION);
  }
Ejemplo n.º 3
0
  protected void drawScene() {
    Log.i(TAG, "----------drawScene------------------------------");

    this.mPhysicsWorld = new PhysicsWorld(new Vector2(0, 0), false);
    this.registerUpdateHandler(mPhysicsWorld);
    this.mPhysicsWorld.setContactListener(contactListener);

    final Sprite spriteBackGround =
        new Sprite(
            960 / 2 - mBackGroundTextureRegion.getWidth() / 2,
            0,
            mBackGroundTextureRegion,
            mVertexBufferObjectManager);
    this.attachChild(spriteBackGround);

    for (int i = 0; i < mTabSprite.length; i++) {
      mTabSprite[i] =
          new Sprite(
              960 / 2 - 1150 / 2,
              89.5f,
              tpTab[i].getTexturePackTextureRegionLibrary().get(0),
              mVertexBufferObjectManager);
      this.attachChild(mTabSprite[i]);
      mTabSprite[i].setVisible(false);
    }
    mTabSprite[0].setVisible(true);

    final Body body =
        this.physicsEditorShapeLibrary.createBody(
            "a3_5_1_iphone_dai", mTabSprite[0], this.mPhysicsWorld);
    this.mPhysicsWorld.registerPhysicsConnector(
        new PhysicsConnector(mTabSprite[0], body, true, true));
    mTabSprite[0].setUserData(body);

    // Cubic Choose
    mCubicChooseSpite[CUBIC_YELLOW] =
        new Sprite(
            279,
            70,
            tpOne
                .getTexturePackTextureRegionLibrary()
                .get(Vol3OsyougatsuResource.packer_parta_1.A3_6_4_IPHONE_KOMA_ID),
            mVertexBufferObjectManager);
    this.attachChild(mCubicChooseSpite[CUBIC_YELLOW]);

    mCubicChooseSpite[CUBIC_GREEN] =
        new Sprite(
            200,
            90f,
            tpOne
                .getTexturePackTextureRegionLibrary()
                .get(Vol3OsyougatsuResource.packer_parta_1.A3_6_3_IPHONE_KOMA_ID),
            mVertexBufferObjectManager);
    this.attachChild(mCubicChooseSpite[CUBIC_GREEN]);

    mCubicChooseSpite[CUBIC_BLUE] =
        new Sprite(
            110,
            107,
            tpOne
                .getTexturePackTextureRegionLibrary()
                .get(Vol3OsyougatsuResource.packer_parta_1.A3_6_2_IPHONE_KOMA_ID),
            mVertexBufferObjectManager);
    this.attachChild(mCubicChooseSpite[CUBIC_BLUE]);

    mCubicChooseSpite[CUBIC_ORANGE] =
        new Sprite(
            22f,
            135,
            tpOne
                .getTexturePackTextureRegionLibrary()
                .get(Vol3OsyougatsuResource.packer_parta_1.A3_6_1_IPHONE_KOMA_ID),
            mVertexBufferObjectManager);
    this.attachChild(mCubicChooseSpite[CUBIC_ORANGE]);

    cubicTouch = new CubicTouch(0, 0, 960, 640, null);
    this.attachChild(cubicTouch);
    this.registerTouchArea(cubicTouch);

    for (int i = CUBIC_ORANGE; i <= CUBIC_YELLOW; i++) {
      final TextureRegion iOTextureRegion =
          new TextureRegion(
              bitmapTexture[i % 2],
              2,
              2,
              mCubicStartTiledTexture[i].getWidth(),
              mCubicStartTiledTexture[i].getHeight());
      mCubicEntity[i] =
          new CubicEntity(
              0,
              100,
              i,
              mCubicStartTiledTexture[i],
              mCubicTurnTiledTexture[i],
              mCubicStopTiledTexture[i],
              mCubicTurnOptionTiledTexture,
              iOTextureRegion);
      this.attachChild(mCubicEntity[i]);
      mCubicEntity[i].setVisible(false);
      // Body
      final Body bodyCubic =
          this.physicsEditorShapeLibrary.createBody(
              CUBIC_BODYNAME[i], mCubicEntity[i], this.mPhysicsWorld);
      bodyCubic.setFixedRotation(true);
      bodyCubic.setActive(false);
      mCubicEntity[i].setUserData(bodyCubic);
      mPhysicsWorld.registerPhysicsConnector(
          new PhysicsConnector(mCubicEntity[i], bodyCubic, true, true));
    }

    final SceneTouch sceneTouch = new SceneTouch(0, 0, 960, 640, null);
    this.attachChild(sceneTouch);
    this.registerTouchArea(sceneTouch);

    mSuzuAniSprite =
        new AnimatedSprite(
            960 / 2 - mSuzuTiledTexTure.getWidth() / 2,
            -19,
            mSuzuTiledTexTure,
            mVertexBufferObjectManager);
    this.attachChild(mSuzuAniSprite);

    mShishiAniSprite =
        new AnimatedSprite(960, 59.5f, mShishiTiledTexTure, mVertexBufferObjectManager);
    this.attachChild(mShishiAniSprite);
    mShishiAniSprite.setVisible(false);

    mArrowSprite =
        new Sprite(
            120,
            133,
            tpThree
                .getTexturePackTextureRegionLibrary()
                .get(Vol3OsyougatsuResource.packer_parta_3.A3_8_1_IPHONE_YAJIRUSHI_ID),
            mVertexBufferObjectManager);
    this.attachChild(mArrowSprite);
    mArrowSprite.setVisible(false);
  }