예제 #1
0
  @Override
  public Scene onLoadScene() {
    mEngine.registerUpdateHandler(new FPSLogger());

    final int barX = (int) ((mCamera.getWidth() - mBarTextureRegion.getWidth()) / 2);
    ballX = barX;
    final int barY = (int) ((mCamera.getHeight() - mBarTextureRegion.getHeight()) / 2);

    // player = new Sprite(PlayerX, PlayerY, mPlayerTextureRegion);
    // player.setScale(2);

    bar = new Sprite(barX, barY, mBarTextureRegion);
    bar.setScale(4, 2.5f);

    ball = new Sprite(ballX, barY + bar.getHeight(), mBallTextureRegion);
    ball.setScale(2.5f);

    mMainScene = new Scene();
    mMainScene.setBackground(new ColorBackground(0.09804f, 0.6274f, 0.8784f));

    // mMainScene.attachChild(player);
    mMainScene.attachChild(bar);
    mMainScene.attachChild(ball);

    mMainScene.registerUpdateHandler(detect);

    // projectileLL = new LinkedList();
    // projectilesToBeAdded = new LinkedList();

    mMainScene.setOnSceneTouchListener(this);

    mPauseScene = new CameraScene(mCamera);
    final int x = (int) (mCamera.getWidth() / 2 - mPausedTextureRegion.getWidth() / 2);
    final int y = (int) (mCamera.getHeight() / 2 - mPausedTextureRegion.getHeight() / 2);
    final Sprite pausedSprite = new Sprite(x, y, mPausedTextureRegion);
    mPauseScene.attachChild(pausedSprite);
    mPauseScene.setBackgroundEnabled(false);

    mResultScene = new CameraScene(mCamera);
    winSprite = new Sprite(x, y, mWinTextureRegion);
    failSprite = new Sprite(x, y, mFailTextureRegion);
    mResultScene.attachChild(winSprite);
    mResultScene.attachChild(failSprite);
    mResultScene.setBackgroundEnabled(false);

    winSprite.setVisible(false);
    failSprite.setVisible(false);
    score = new ChangeableText(0, 0, mFont, "ButtsButtsButts");
    score.setPosition(5, 5); // mCamera.getWidth() - score.getWidth() - 5, 5);
    score.setWidth(2000);
    mMainScene.attachChild(score);

    sensorManager = (SensorManager) this.getSystemService(this.SENSOR_SERVICE);
    sensorManager.registerListener(
        this, sensorManager.getDefaultSensor(Sensor.TYPE_ROTATION_VECTOR), 1);

    return mMainScene;
  }
 public void addFace(final int pID, final float pX, final float pY) {
   final Scene scene = this.mEngine.getScene();
   /* Create the face and add it to the scene. */
   final Sprite face = new Sprite(0, 0, this.mFaceTextureRegion);
   face.setPosition(pX - face.getWidth() * 0.5f, pY - face.getHeight() * 0.5f);
   face.setUserData(pID);
   this.mFaces.put(pID, face);
   scene.registerTouchArea(face);
   scene.attachChild(face);
 }
 public void moveFace(final int pID, final float pX, final float pY) {
   /* Find and move the face. */
   final Sprite face = this.mFaces.get(pID);
   face.setPosition(pX - face.getWidth() * 0.5f, pY - face.getHeight() * 0.5f);
 }