public Scene onCreateScene() {
    this.mEngine.registerUpdateHandler(new FPSLogger());

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

    boton =
        new ButtonSprite(
            100,
            100,
            this.mBotonTextureRegion,
            this.getVertexBufferObjectManager(),
            new OnClickListener() {

              public void onClick(
                  ButtonSprite pButtonSprite, float pTouchAreaLocalX, float pTouchAreaLocalY) {
                boton.setPosition(boton.getX() + 20, boton.getY() + 20);
              }
            });

    scene.attachChild(boton);
    scene.registerTouchArea(boton);

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

    /* Create a nice scene with some rectangles. */
    final Scene scene = new Scene();

    final Entity rectangleGroup =
        new Entity(MotionStreakExample.CAMERA_WIDTH / 2, MotionStreakExample.CAMERA_HEIGHT / 2);

    rectangleGroup.attachChild(this.makeColoredRectangle(-180, -180, 1, 0, 0));
    rectangleGroup.attachChild(this.makeColoredRectangle(0, -180, 0, 1, 0));
    rectangleGroup.attachChild(this.makeColoredRectangle(0, 0, 0, 0, 1));
    rectangleGroup.attachChild(this.makeColoredRectangle(-180, 0, 1, 1, 0));

    /* Spin the rectangles. */
    rectangleGroup.registerEntityModifier(
        new LoopEntityModifier(
            new SequenceEntityModifier(
                new RotationModifier(10, 0, 7200, EaseQuadInOut.getInstance()),
                new DelayModifier(2))));

    scene.attachChild(rectangleGroup);

    /* TouchListener */
    scene.setOnSceneTouchListener(this);

    return scene;
  }
  @Override
  public boolean onMenuItemClicked(
      MenuScene pMenuScene, IMenuItem pMenuItem, float pMenuItemLocalX, float pMenuItemLocalY) {
    // TODO Auto-generated method stub
    switch (pMenuItem.getID()) {
      case MENU_PLAY:
        mainMenuScene.registerEntityModifier(new ScaleModifier(1.0f, 1.0f, 0.0f));
        mStaticMenuScene.registerEntityModifier(new ScaleModifier(1.0f, 1.0f, 0.0f));
        mHandler.postDelayed(mLaunchLevel1Task, 1000);
        return true;

      case MENU_OPTIONS:
        mainMenuScene.registerEntityModifier(new ScaleModifier(1.0f, 1.0f, 0.0f));
        mStaticMenuScene.registerEntityModifier(new ScaleModifier(1.0f, 1.0f, 0.0f));
        mHandler.postDelayed(mLaunchOptionsTask, 1000);
        return true;

      case MENU_HELP:
        mHandler.postDelayed(mLaunchHelp, 1000);
        return true;

      default:
        return false;
    }
  }
  @Override
  public Scene onCreateSceneAsync(final IProgressListener pProgressListener) throws Exception {
    this.mEngine.registerUpdateHandler(new FPSLogger());

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

    return scene;
  }
Exemple #5
0
  @Override
  public void onCreateScene(OnCreateSceneCallback pOnCreateSceneCallback) throws Exception {
    this.mEngine.registerUpdateHandler(new FPSLogger());

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

    final float centerX = (CAMERA_WIDTH - this.mFaceTextureRegion.getWidth()) / 2;
    final float centerY = (CAMERA_HEIGHT - this.mFaceTextureRegion.getHeight()) / 2;
    final Sprite face =
        new Sprite(centerX, centerY, this.mFaceTextureRegion, this.getVertexBufferObjectManager());
    final PhysicsHandler physicsHandler = new PhysicsHandler(face);
    face.registerUpdateHandler(physicsHandler);

    scene.attachChild(face);

    final AnalogOnScreenControl analogOnScreenControl =
        new AnalogOnScreenControl(
            0,
            CAMERA_HEIGHT - this.mOnScreenControlBaseTextureRegion.getHeight(),
            this.mCamera,
            this.mOnScreenControlBaseTextureRegion,
            this.mOnScreenControlKnobTextureRegion,
            0.1f,
            200,
            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) {
                face.registerEntityModifier(
                    new SequenceEntityModifier(
                        new ScaleModifier(0.25f, 1, 1.5f), new ScaleModifier(0.25f, 1.5f, 1)));
              }
            });
    analogOnScreenControl
        .getControlBase()
        .setBlendFunction(GLES20.GL_SRC_ALPHA, GLES20.GL_ONE_MINUS_SRC_ALPHA);
    analogOnScreenControl.getControlBase().setAlpha(0.5f);
    analogOnScreenControl.getControlBase().setScaleCenter(0, 128);
    analogOnScreenControl.getControlBase().setScale(1.25f);
    analogOnScreenControl.getControlKnob().setScale(1.25f);
    analogOnScreenControl.refreshControlKnobPosition();

    scene.setChildScene(analogOnScreenControl);

    pOnCreateSceneCallback.onCreateSceneFinished(scene);
  }
  public LevelViewButtonSelector attachButtonsToScene(Scene pScene, boolean pTouchEn) {
    for (LevelViewButton btn : getButtons()) {
      pScene.attachChild(btn);

      if (pTouchEn == true) {
        pScene.registerTouchArea(btn);
      }
    }

    return this;
  }
  @Override
  public Scene onCreateScene() {
    final Scene scene = new Scene();
    scene.getBackground().setColor(0.09804f, 0.6274f, 0.8784f);

    //		this.drawUsingSprites(scene);
    //		this.drawUsingSpritesWithSharedVertexBuffer(scene);
    this.drawUsingSpriteBatch(scene);

    return scene;
  }
  public LevelViewButtonSelector attachButtonsToScene(
      Scene pScene, boolean pTouchEn, IEntityModifier pEntityModifier) {
    for (LevelViewButton btn : getButtons()) {
      pScene.attachChild(btn);

      if (pTouchEn == true) {
        pScene.registerTouchArea(btn);
      }
      btn.registerEntityModifier(pEntityModifier);
    }

    return this;
  }
Exemple #9
0
  @Override
  protected Scene onCreateScene() {
    Scene scene = new Scene();
    this.tmxLayer =
        this.tiledMap
            .getTMXLayers()
            .get(
                0); // the 0 is just an index of the layer. It depends on how many layers you
                    // created within Tiled
    scene.attachChild(this.tmxLayer);

    return scene;
  }
  @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, 0, 0));

    for (int i = 0; i < COUNT; i++) {
      final float tension = MathUtils.random(-0.5f, 0.5f);
      this.addRectangleWithTension(scene, tension, MathUtils.random(0, DURATION * 2f));
    }

    return scene;
  }
  public void addGimmicsButton(
      Scene mScene,
      String[] sound,
      int[] image,
      TexturePackTextureRegionLibrary pTexturePackTextureRegionLibrary) {

    ITextureRegion[] ttrGimmic = new ITextureRegion[3];
    sprGimmic = new Sprite[3];
    final Sound[] sndGimmic = new Sound[3];
    int[] start = {244, 436, 612};

    for (int i = 0; i < sprGimmic.length; i++) {
      // load sound
      sndGimmic[i] = loadSoundResourceFromSD(sound[i]);

      ttrGimmic[i] = pTexturePackTextureRegionLibrary.get(image[i]);
      final int tmp = i;
      sprGimmic[i] =
          new Sprite(start[i], 496, ttrGimmic[i], this.getVertexBufferObjectManager()) {

            @Override
            public boolean onAreaTouched(
                final TouchEvent pSceneTouchEvent,
                final float pTouchAreaLocalX,
                final float pTouchAreaLocalY) {
              if (pSceneTouchEvent.getAction() == TouchEvent.ACTION_DOWN) {
                if (isTouchGimmic[tmp]) {
                  if (tmp == 2) {
                    combineGimmic3WithAction();
                  } else {
                    sndGimmic[tmp].play();
                  }
                  sprGimmic[tmp].registerEntityModifier(
                      new SequenceEntityModifier(
                          new ScaleModifier(0.35f, 1, 1.3f), new ScaleModifier(0.35f, 1.3f, 1f)));
                }
                return true;
              }
              return super.onAreaTouched(pSceneTouchEvent, pTouchAreaLocalX, pTouchAreaLocalY);
            }
          };
      mScene.registerTouchArea(sprGimmic[i]);
      mScene.attachChild(sprGimmic[i]);
    }

    mScene.setTouchAreaBindingOnActionDownEnabled(true);
    mScene.setTouchAreaBindingOnActionMoveEnabled(true);
  }
  private void initControl() {
    this.mDigitalOnScreenControl =
        new DigitalOnScreenControl(
            0,
            CAMERA_HEIGHT - this.mOnScreenControlBaseTextureRegion.getHeight(),
            this.mCamera,
            this.mOnScreenControlBaseTextureRegion,
            this.mOnScreenControlKnobTextureRegion,
            0.1f,
            this.getVertexBufferObjectManager(),
            new IOnScreenControlListener() {
              @Override
              public void onControlChange(
                  final BaseOnScreenControl pBaseOnScreenControl,
                  final float pValueX,
                  final float pValueY) {}
            });

    this.mDigitalOnScreenControl
        .getControlBase()
        .setBlendFunction(GLES20.GL_SRC_ALPHA, GLES20.GL_ONE_MINUS_SRC_ALPHA);
    this.mDigitalOnScreenControl.getControlBase().setAlpha(0.5f);
    this.mDigitalOnScreenControl.getControlBase().setScaleCenter(0, 128);
    this.mDigitalOnScreenControl.getControlBase().setScale(1.25f);
    this.mDigitalOnScreenControl.getControlKnob().setScale(1.25f);
    this.mDigitalOnScreenControl.refreshControlKnobPosition();

    mScene.setChildScene(this.mDigitalOnScreenControl);
  }
  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);
  }
  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);
    }
  }
  private void testSceneTouchWorker(
      final Scene pScene,
      final int pSurfaceTouchX,
      final int pSurfaceTouchY,
      final float pExpectedX,
      final float pExpectedY) {
    pScene.setOnSceneTouchListener(
        new IOnSceneTouchListener() {
          @Override
          public boolean onSceneTouchEvent(final Scene pScene, final TouchEvent pSceneTouchEvent) {
            final float actualX = pSceneTouchEvent.getX();
            final float actualY = pSceneTouchEvent.getY();
            Assert.assertEquals(pExpectedX, actualX, DELTA);
            Assert.assertEquals(pExpectedY, actualY, DELTA);
            return true;
          }
        });

    final long uptimeMillis = SystemClock.uptimeMillis();

    final boolean result =
        this.mEngine.onTouch(
            null,
            MotionEvent.obtain(
                uptimeMillis,
                uptimeMillis,
                MotionEvent.ACTION_DOWN,
                pSurfaceTouchX,
                pSurfaceTouchY,
                0));

    Assert.assertTrue(result);
  }
  @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;
  }
  @Override
  protected Scene onCreateScene() {
    this.mEngine.registerUpdateHandler(new FPSLogger());

    final Scene scene = new Scene();

    final CircleOutlineParticleEmitter particleEmitter =
        new CircleOutlineParticleEmitter(
            XMLLayoutExample.CAMERA_WIDTH * 0.5f, (XMLLayoutExample.CAMERA_HEIGHT * 0.5f) + 20, 80);
    final SpriteParticleSystem particleSystem =
        new SpriteParticleSystem(
            particleEmitter,
            60,
            60,
            360,
            this.mParticleTextureRegion,
            this.getVertexBufferObjectManager());

    scene.setOnSceneTouchListener(
        new IOnSceneTouchListener() {
          @Override
          public boolean onSceneTouchEvent(final Scene pScene, final TouchEvent pSceneTouchEvent) {
            particleEmitter.setCenter(pSceneTouchEvent.getX(), pSceneTouchEvent.getY());
            return true;
          }
        });

    particleSystem.addParticleInitializer(new ColorParticleInitializer<Sprite>(1, 0, 0));
    particleSystem.addParticleInitializer(new AlphaParticleInitializer<Sprite>(0));
    particleSystem.addParticleInitializer(
        new BlendFunctionParticleInitializer<Sprite>(GLES20.GL_SRC_ALPHA, GLES20.GL_ONE));
    particleSystem.addParticleInitializer(new VelocityParticleInitializer<Sprite>(-2, 2, -20, -10));
    particleSystem.addParticleInitializer(new RotationParticleInitializer<Sprite>(0.0f, 360.0f));
    particleSystem.addParticleInitializer(new ExpireParticleInitializer<Sprite>(6));

    particleSystem.addParticleModifier(new ScaleParticleModifier<Sprite>(0, 5, 1.0f, 2.0f));
    particleSystem.addParticleModifier(
        new ColorParticleModifier<Sprite>(0, 3, 1, 1, 0, 0.5f, 0, 0));
    particleSystem.addParticleModifier(
        new ColorParticleModifier<Sprite>(4, 6, 1, 1, 0.5f, 1, 0, 1));
    particleSystem.addParticleModifier(new AlphaParticleModifier<Sprite>(0, 1, 0, 1));
    particleSystem.addParticleModifier(new AlphaParticleModifier<Sprite>(5, 6, 1, 0));

    scene.attachChild(particleSystem);

    return scene;
  }
  @Override
  public Scene onCreateScene() {
    mScene = new Scene();
    mScene.setBackground(new Background(0.09804f, 0.6274f, 0.8784f));
    initControl();

    return mScene;
  }
  /**
   * Attach all bird sprites to scene
   *
   * @param scene {scene}
   */
  public void AttachToScene(Scene scene) {
    if (scene == null) return;

    int size = birdSprites.size();
    for (int i = 0; i < size; i++) {
      scene.attachChild(birdSprites.get(i).getAnimatedSprite());
    }
  }
  public void setGimmicBringToFront() {
    if (this.mScene != null) {

      int zIndex = this.mScene.getChild(mScene.getLastChild().getTag()).getZIndex();
      zIndex++;
      this.sprGimmic[0].setZIndex(zIndex++);
      this.sprGimmic[1].setZIndex(zIndex++);
      this.sprGimmic[2].setZIndex(zIndex++);
      this.mScene.sortChildren();
    }
  }
  @Override
  protected Scene initSceneImpl() {
    mTossScene = new Scene();
    final Sprite backgroundSprite =
        new Sprite(0, 0, mBgTextureRegion, getVertexBufferObjectManager());
    mTossScene.attachChild(backgroundSprite);

    Item item = mGame.getPlayer().getItemFromStorage();
    if (item == null) {
      return mTossScene; // should never enter here.
    }
    final Sprite message = new Sprite(5, 20, mMessageBox, getVertexBufferObjectManager());
    mTossScene.attachChild(message);
    int amount = mGame.itemLost(item.getType(), item.getCount());
    mAmountText = new Text(270, 43, mFont, String.valueOf(amount), getVertexBufferObjectManager());
    mTossScene.attachChild(mAmountText);
    TiledSprite itemKind =
        new TiledSprite(95, 43, mLocTextureRegion, getVertexBufferObjectManager());
    itemKind.setCurrentTileIndex(item.getType() - 1);
    mTossScene.attachChild(itemKind);
    return mTossScene;
  }
Exemple #23
0
  // Creer la scene affiche e l'ecran.
  private void initSplashScene() {
    mCurrentScene = new Scene();
    // Sprite qui va contenir le logo
    Sprite splash =
        new Sprite(0, 0, manager.mSplashLogo, mEngine.getVertexBufferObjectManager()) {
          @Override
          protected void preDraw(GLState pGLState, Camera pCamera) {
            super.preDraw(pGLState, pCamera);
            pGLState.enableDither();
          }
        };
    splash.setScale(0.8f);
    // Ajoute le sprite splash e la scene.
    splash.setPosition(
        (mCamera.getWidth() - splash.getWidth()) * 0.5f,
        (mCamera.getHeight() - splash.getHeight() - 150f) * 0.5f);
    mCurrentScene.attachChild(splash);

    // Attache le titre
    mCurrentScene.attachChild(mTitle1);
    mCurrentScene.attachChild(mTitle2);
  }
Exemple #24
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;
  }
Exemple #25
0
  /** Display the LevelSelector on the Scene. */
  public void show() {

    /* Register as non-hidden, allowing touch events */
    mHidden = false;

    /* Attach the LevelSelector the the Scene if it currently has no parent */
    if (!this.hasParent()) {
      mScene.attachChild(this);
    }

    /* Set the LevelSelector to visible */
    this.setVisible(true);
  }
  private void addRectangleWithTension(final Scene pScene, final float pTension, float pDelay) {
    final Rectangle rectangle =
        new Rectangle(-SIZE, -SIZE, SIZE, SIZE, this.getVertexBufferObjectManager());
    rectangle.setBlendFunction(GLES20.GL_SRC_ALPHA, GLES20.GL_ONE);
    if (pTension < 0) {
      rectangle.setColor(1 - pTension, 0, 0, 0.5f);
    } else {
      rectangle.setColor(pTension, 0, 0, 0.5f);
    }

    final CardinalSplineMoveModifierConfig catmullRomMoveModifierConfig1 =
        new CardinalSplineMoveModifierConfig(
            CardinalSplineMoveModifierExample.CONTROLPOINT_1_XS.length, pTension);
    final CardinalSplineMoveModifierConfig catmullRomMoveModifierConfig2 =
        new CardinalSplineMoveModifierConfig(
            CardinalSplineMoveModifierExample.CONTROLPOINT_1_XS.length, pTension);

    for (int i = 0; i < CardinalSplineMoveModifierExample.CONTROLPOINT_1_XS.length; i++) {
      catmullRomMoveModifierConfig1.setControlPoint(
          i,
          CardinalSplineMoveModifierExample.CONTROLPOINT_1_XS[i] - SIZE / 2,
          CardinalSplineMoveModifierExample.CONTROLPOINT_YS[i] - SIZE / 2);
      catmullRomMoveModifierConfig2.setControlPoint(
          i,
          CardinalSplineMoveModifierExample.CONTROLPOINT_2_XS[i] - SIZE / 2,
          CardinalSplineMoveModifierExample.CONTROLPOINT_YS[i] - SIZE / 2);
    }

    rectangle.registerEntityModifier(
        new SequenceEntityModifier(
            new DelayModifier(pDelay),
            new LoopEntityModifier(
                new SequenceEntityModifier(
                    new ParallelEntityModifier(
                        new CardinalSplineMoveModifier(
                            CardinalSplineMoveModifierExample.DURATION,
                            catmullRomMoveModifierConfig1,
                            EaseLinear.getInstance()),
                        new RotationModifier(
                            CardinalSplineMoveModifierExample.DURATION, -45, -315)),
                    new ParallelEntityModifier(
                        new CardinalSplineMoveModifier(
                            CardinalSplineMoveModifierExample.DURATION,
                            catmullRomMoveModifierConfig2,
                            EaseLinear.getInstance()),
                        new RotationModifier(
                            CardinalSplineMoveModifierExample.DURATION, 45, 315))))));

    pScene.attachChild(rectangle);
  }
  @Override
  public void onPopulateSceneAsync(final Scene pScene, final IProgressListener pProgressListener)
      throws Exception {
    /* Calculate the coordinates for the face, so its centered on the camera */
    final float centerX =
        (AsyncGameActivityExample.CAMERA_WIDTH - this.mFaceTextureRegion.getWidth()) / 2;
    final float centerY =
        (AsyncGameActivityExample.CAMERA_HEIGHT - this.mFaceTextureRegion.getHeight()) / 2;

    /* Create the face and add it to the scene */
    final Sprite face =
        new Sprite(centerX, centerY, this.mFaceTextureRegion, this.getVertexBufferObjectManager());
    pScene.attachChild(face);
  }
  @Override
  protected Scene onCreateScene() {
    this.mEngine.registerUpdateHandler(new FPSLogger());
    // TODO Auto-generated method stub
    scene = new Scene();
    try {
      final TMXLoader tmxLoader =
          new TMXLoader(
              this.getAssets(),
              this.mEngine.getTextureManager(),
              TextureOptions.BILINEAR_PREMULTIPLYALPHA,
              this.getVertexBufferObjectManager(),
              new ITMXTilePropertiesListener() {
                @Override
                public void onTMXTileWithPropertiesCreated(
                    final TMXTiledMap pTMXTiledMap,
                    final TMXLayer pTMXLayer,
                    final TMXTile pTMXTile,
                    final TMXProperties<TMXTileProperty> pTMXTileProperties) {}
              });
      this.mTMXTiledMap = tmxLoader.loadFromAsset("tmx/map_pro.tmx");

    } catch (final TMXLoadException e) {
      Debug.e(e);
    }
    final TMXLayer tmxLayer = this.mTMXTiledMap.getTMXLayers().get(0);

    scene.attachChild(tmxLayer);

    /* Make the camera not exceed the bounds of the TMXEntity. */
    this.mBoundChaseCamera.setBounds(0, 0, tmxLayer.getHeight(), tmxLayer.getWidth());
    this.mBoundChaseCamera.setBoundsEnabled(true);

    final float centerX = (MyCamera.CAMERA_WIDTH - this.mFaceTextureRegion.getWidth()) / 2;
    final float centerY = (MyCamera.CAMERA_HEIGHT - this.mFaceTextureRegion.getHeight()) / 2;
    face =
        new Sprite(centerX, centerY, this.mFaceTextureRegion, this.getVertexBufferObjectManager());

    scene.attachChild(face);

    // Add playerSprite to screen
    initplayerSprite(scene, this.mPlayerTextureRegion);

    // Scene UpdateHandler

    scene.setTouchAreaBindingOnActionDownEnabled(true);
    scene.setOnAreaTouchListener(pOnAreaTouchListener);
    scene.registerUpdateHandler(pUpdateHandler);
    scene.registerTouchArea(tmxLayer);
    scene.setOnSceneTouchListener(pOnSceneTouchListener);
    return scene;
  }
  @Override
  public synchronized void onResumeGame() {
    // TODO Auto-generated method stub

    // sa.finish();
    super.onResumeGame();
    mainMenuScene.registerEntityModifier(
        new ScaleAtModifier(0.5f, 0.0f, 1.0f, CAMERA_WIDTH / 2, CAMERA_HEIGHT / 2));
    mStaticMenuScene.registerEntityModifier(
        new ScaleAtModifier(0.5f, 0.0f, 1.0f, CAMERA_WIDTH / 2, CAMERA_HEIGHT / 2));

    if (audioOptions.getBoolean("musicOn", true)) {
      StartActivity.mMusic.resume();
    }
  }
Exemple #30
0
  @Override
  public void onPopulateScene(final Scene pScene, OnPopulateSceneCallback pOnPopulateSceneCallback)
      throws Exception {
    this.initDimension();
    this.initAction();
    this.initMatrix();
    this.initHeader();
    this.initPlate();
    this.initScore();
    this.initBulles();

    pScene.setTouchAreaBindingOnActionDownEnabled(true);

    super.onPopulateScene(pScene, pOnPopulateSceneCallback);
  }