コード例 #1
0
  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);
  }
コード例 #2
0
  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));
  }
コード例 #3
0
 @Override
 public void onAccelerometerChanged(final AccelerometerData pAccelerometerData) {
   mTempVector.set(pAccelerometerData.getY(), pAccelerometerData.getX());
   mPhysicsWorld.setGravity(mTempVector);
 }