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));
  }
 // This simple creates the scene
 // That can hold other objects too
 @Override
 public Scene onLoadScene() {
   mEngine.registerUpdateHandler(new FPSLogger());
   // Create a scene 'myscene' object
   Scene myscene = new Scene();
   // Create one animated Sprite
   AnimatedSprite banana = new AnimatedSprite(100, 100, mTiledTextureRegion);
   // Attach sprite to the scene
   myscene.attachChild(banana);
   // set the time in milisec for each picture
   banana.animate(100);
   return myscene;
 }
Exemple #3
0
  public void update(Scene getmMainScene) {
    if (sprite != null) {
      if (getType() == -1) {
        sprite.stopAnimation();
        sprite.setCurrentTileIndex(2, 0);
      } else if (isBig()) {
        if (isChecked()) {
          sprite.setCurrentTileIndex(0, getType());
          sprite.animate(
              new long[] {100, 100, 100}, (getType() - 1) * 3, (getType() - 1) * 3 + 2, true);
        } else {
          sprite.stopAnimation();
          sprite.setCurrentTileIndex(0, getType() - 1);
        }

      } else {
        sprite.stopAnimation();
        sprite.setCurrentTileIndex(1, (getType() / 10) - 1);
      }
    }
  }