private void addFace(final float pX, final float pY) {
    final Scene scene = mEngine.getScene();

    mFaceCount++;

    final AnimatedSprite face;
    final Body body;

    final FixtureDef objectFixtureDef = PhysicsFactory.createFixtureDef(1, 0.5f, 0.5f);

    if (mFaceCount % 2 == 0) {
      face = new AnimatedSprite(pX, pY, mBoxFaceTextureRegion);
      body =
          PhysicsFactory.createBoxBody(mPhysicsWorld, face, BodyType.DynamicBody, objectFixtureDef);
    } else {
      face = new AnimatedSprite(pX, pY, mCircleFaceTextureRegion);
      body =
          PhysicsFactory.createCircleBody(
              mPhysicsWorld, face, BodyType.DynamicBody, objectFixtureDef);
    }

    face.animate(200, true);

    scene.registerTouchArea(face);
    scene.getLastChild().attachChild(face);
    mPhysicsWorld.registerPhysicsConnector(new PhysicsConnector(face, body, true, true));
  }
Ejemplo n.º 2
0
  @Override
  public Scene onLoadScene() {
    this.mEngine.registerUpdateHandler(new FPSLogger());

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

    /* Calculate the coordinates for the screen-center. */
    final int centerX = (CAMERA_WIDTH - this.mFaceTextureRegion.getWidth()) / 2;
    final int centerY = (CAMERA_HEIGHT - this.mFaceTextureRegion.getHeight()) / 2;

    /* Create some faces and add them to the scene. */
    final IEntity lastChild = scene.getLastChild();
    lastChild.attachChild(new Sprite(centerX - 25, centerY - 25, this.mFaceTextureRegion));
    lastChild.attachChild(new Sprite(centerX + 25, centerY - 25, this.mFaceTextureRegion));
    lastChild.attachChild(new Sprite(centerX, centerY + 25, this.mFaceTextureRegion));

    scene.setOnSceneTouchListener(
        new IOnSceneTouchListener() {
          @Override
          public boolean onSceneTouchEvent(final Scene pScene, final TouchEvent pSceneTouchEvent) {
            switch (pSceneTouchEvent.getAction()) {
              case TouchEvent.ACTION_DOWN:
                ZoomExample.this.mSmoothCamera.setZoomFactor(5.0f);
                break;
              case TouchEvent.ACTION_UP:
                ZoomExample.this.mSmoothCamera.setZoomFactor(1.0f);
                break;
            }
            return true;
          }
        });

    return scene;
  }
  private void removeFace(final AnimatedSprite face) {
    final Scene scene = mEngine.getScene();

    final PhysicsConnector facePhysicsConnector =
        mPhysicsWorld.getPhysicsConnectorManager().findPhysicsConnectorByShape(face);

    mPhysicsWorld.unregisterPhysicsConnector(facePhysicsConnector);
    mPhysicsWorld.destroyBody(facePhysicsConnector.getBody());

    scene.unregisterTouchArea(face);
    scene.getLastChild().detachChild(face);
  }
  @Override
  public Scene onLoadScene() {
    final Scene scene = new Scene(1);
    scene.setBackground(new ColorBackground(0.1f, 0.6f, 0.9f));
    scene.setOnSceneTouchListener(
        new IOnSceneTouchListener() {
          @Override
          public boolean onSceneTouchEvent(final Scene pScene, final TouchEvent pSceneTouchEvent) {
            switch (pSceneTouchEvent.getAction()) {
              case TouchEvent.ACTION_DOWN:
                Toast.makeText(AndEngineTouchExample.this, "Scene touch DOWN", Toast.LENGTH_SHORT)
                    .show();
                break;
              case TouchEvent.ACTION_UP:
                Toast.makeText(AndEngineTouchExample.this, "Scene touch UP", Toast.LENGTH_SHORT)
                    .show();
                break;
            }
            return true;
          }
        });

    mIcon =
        new Sprite(100, 100, this.mIconTextureRegion) {
          @Override
          public boolean onAreaTouched(
              final TouchEvent pAreaTouchEvent,
              final float pTouchAreaLocalX,
              final float pTouchAreaLocalY) {
            switch (pAreaTouchEvent.getAction()) {
              case TouchEvent.ACTION_DOWN:
                Toast.makeText(AndEngineTouchExample.this, "Sprite touch DOWN", Toast.LENGTH_SHORT)
                    .show();
                break;
              case TouchEvent.ACTION_UP:
                Toast.makeText(AndEngineTouchExample.this, "Sprite touch UP", Toast.LENGTH_SHORT)
                    .show();
                break;
            }
            return true;
          }
        };

    scene.getLastChild().attachChild(mIcon);
    scene.registerTouchArea(mIcon);
    scene.setTouchAreaBindingEnabled(true);

    return scene;
  }
Ejemplo n.º 5
0
  @Override
  public Scene onLoadScene() {
    this.mEngine.registerUpdateHandler(new FPSLogger());

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

    /* Create the icons and add them to the scene. */
    final IEntity lastChild = scene.getLastChild();

    lastChild.attachChild(new Sprite(160 - 24, 106 - 24, this.mPngTextureRegion));
    lastChild.attachChild(new Sprite(160 - 24, 213 - 24, this.mJpgTextureRegion));
    lastChild.attachChild(new Sprite(320 - 24, 106 - 24, this.mGifTextureRegion));
    lastChild.attachChild(new Sprite(320 - 24, 213 - 24, this.mBmpTextureRegion));

    return scene;
  }
Ejemplo n.º 6
0
  @Override
  public Scene onLoadScene() {
    this.mEngine.registerUpdateHandler(new FPSLogger());

    this.createOptionsMenuScene();

    /* Center the background on the camera. */
    final int centerX = (CAMERA_WIDTH - this.mMenuBackTextureRegion.getWidth()) / 2;
    final int centerY = (CAMERA_HEIGHT - this.mMenuBackTextureRegion.getHeight()) / 2;

    this.mMainScene = new Scene(1);
    /* Add the background and static menu */
    final Sprite menuBack = new Sprite(centerX, centerY, this.mMenuBackTextureRegion);
    mMainScene.getLastChild().attachChild(menuBack);
    mMainScene.setChildScene(mOptionsMenuScene);

    return this.mMainScene;
  }
  public Scene onLoadScene() {
    this.mEngine.registerUpdateHandler(new FPSLogger());

    mMainScene = new Scene(1);
    mMainScene.setBackground(new ColorBackground(0xff, 0xff, 0xff));

    sprLogo = new Sprite(0, 0, txtrLogo);

    mMainScene.getLastChild().attachChild(sprLogo);

    mEngine.registerUpdateHandler(
        new TimerHandler(
            LOGO_DURATION,
            new ITimerCallback() {

              public void onTimePassed(TimerHandler arg0) {
                // TODO .Auto-generated method stub
                FadeOutModifier prFadeOutModifier =
                    new FadeOutModifier(
                        0.5f,
                        new IEntityModifierListener() {

                          public void onModifierFinished(
                              IModifier<IEntity> pModifier, IEntity pItem) {

                            Intent intent =
                                new Intent(StateLogoBubbleFish.this, State_IntroMenu.class);
                            startActivity(intent);
                            finish();
                          }
                        },
                        EaseLinear.getInstance());
                sprLogo.setBlendFunction(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
                sprLogo.registerEntityModifier(prFadeOutModifier);
              }
            }));

    return mMainScene;
  }