How to count lap in GLES2
private void initOnScreenControls() {
final AnalogOnScreenControl analogOnScreenControl = new
AnalogOnScreenControl(0, CAMERA_HEIGHT -
this.mOnScreenControlBaseTextureRegion.getHeight(), this.mCamera,
this.mOnScreenControlBaseTextureRegion,
this.mOnScreenControlKnobTextureRegion, 0.1f,
this.getVertexBufferObjectManager(), new
IAnalogOnScreenControlListener() {
@Override
public void onControlChange(final BaseOnScreenControl
pBaseOnScreenControl, final float pValueX, final float pValueY) {
final Body carBody = RacerGameActivity.this.mCarBody;
final Vector2 velocity = Vector2Pool.obtain(pValueX * 5,
pValueY * 5);
carBody.setLinearVelocity(velocity);
Vector2Pool.recycle(velocity);
final float rotationInRad = (float)Math.atan2(-pValueX, pValueY);
carBody.setTransform(carBody.getWorldCenter(), rotationInRad);
RacerGameActivity.this.mCar.setRotation(MathUtils.radToDeg(rotationInRad));
}
@Override
public void onControlClick(final AnalogOnScreenControl
pAnalogOnScreenControl) {
/* Nothing. */
}
});
analogOnScreenControl.getControlBase().setBlendFunction(GLES20.GL_SRC_ALPHA,
GLES20.GL_ONE_MINUS_SRC_ALPHA);
analogOnScreenControl.getControlBase().setAlpha(0.5f);
// analogOnScreenControl.getControlBase().setScaleCenter(0, 128);
// analogOnScreenControl.getControlBase().setScale(0.75f);
// analogOnScreenControl.getControlKnob().setScale(0.75f);
analogOnScreenControl.refreshControlKnobPosition();
this.mScene.setChildScene(analogOnScreenControl);
}
I control car by AnalogOnScreenControl. But, how to i can count Lap of car
when it run around screen because AnalogOnScreenControl alway update new
coodinates. I want to finish lap at x = 64 and y < 64 and count time to
finish lap. Anyone have idea?
No comments:
Post a Comment