AndEngineを使用して簡単なゲームを作成しています。一定の速度で動き回るスプライトがあります。スプライトが壁にぶつかったり、接触点で衝突したりしたときに、ポイント(+1)、(+ 2)などを表示できる必要があります。テキストを使用してこれを行うにはどうすればよいですか?
AndEngineの例「MovingBallExample.java」の修正バージョンを使用しています。以下のコードは、ボールが壁に当たったときにボールがどのように方向を反転するかを示しています。連絡先にテキストを表示する必要があります。できれば円で数秒間表示する必要があります。
private static class Ball extends AnimatedSprite {
private final PhysicsHandler mPhysicsHandler;
public Ball(final float pX, final float pY, final TiledTextureRegion pTextureRegion, final VertexBufferObjectManager pVertexBufferObjectManager) {
super(pX, pY, pTextureRegion, pVertexBufferObjectManager);
this.mPhysicsHandler = new PhysicsHandler(this);
this.registerUpdateHandler(this.mPhysicsHandler);
this.mPhysicsHandler.setVelocity(BALL_VELOCITY, BALL_VELOCITY);
}
@Override
protected void onManagedUpdate(final float pSecondsElapsed) {
if(this.mX < 0) {
this.mPhysicsHandler.setVelocityX(BALL_VELOCITY);
} else if(this.mX + this.getWidth() > CAMERA_WIDTH) {
//**** Need to add Points text here **********/
this.mPhysicsHandler.setVelocityX(-BALL_VELOCITY);
}
if(this.mY < 0) {
this.mPhysicsHandler.setVelocityY(BALL_VELOCITY);
} else if(this.mY + this.getHeight() + 80 > CAMERA_HEIGHT) {
//**** Need to add Points text here **********/
this.mPhysicsHandler.setVelocityY(-BALL_VELOCITY);
}
どんな考えでも大歓迎です。