我想让球体向前移动给定的厘米数,但到目前为止我还没有设法让任何东西正常工作这是我现在拥有的代码:
EditText distanceText = (EditText) findViewById(R.id.distanceText);
int inputMSec = Integer.parseInt(distanceText.getText().toString());
int time = (inputMSec - inputMSec/2);
// The ball is given the RollCommand at half speed.
RollCommand.sendCommand(mRobot, heading,0.5f);
// A handler is created to delay the Stop command.
final Handler handler = new Handler();
handler.postDelayed(new Runnable(){
@Override
public void run() {
// Makes the ball stop
RollCommand.sendStop(mRobot);
}
// The variable 'time' defines how long the ball rolls until it is told to stop.
}, time);
我可以向球发送任何其他命令而不是 RollCommand 吗?或者任何人都可以找出如何处理来自 EditText 的输入以使距离正确吗?