更新时间:2023-11-22 22:44:58
所以,您想保留位置随时间变化的随机变化,还希望通过键盘输入添加变化,对吧?!
so, you want to keep the the random changes of the position by time and also add a change by keyboard inpput , right?!
尝试:
counterTime += Gdx.graphics.getDeltaTime();
time += delta;
if(counterTime > 2f ) {// each second ==> one call to position random
position = new Vector2(this.mari.x, this.mari.y);
counterTime =0f;
}else { // between 2 seconds
if(Gdx.input.isKeyPressed(Keys.B)) { // if "B" of Keyboard is pressed
counterTime =3f; // go directly to the next random position
}
}