我正在做一个射击游戏并用数组添加很多敌人,然后在地图上给他们一个随机的位置,但我不知道如何让他们到达他们的位置后移动。这是我的敌人课:
import com.badlogic.gdx.math.Vector2;
import java.util.Random;
public class Enemy {
private static final Random r = new Random();
int x = r.nextInt(36);
int y = r.nextInt(24);
Vector2 vect = new Vector2(x,y);
float ROTATION_SPEED = 500;
public Follower(float SPEED, float rotation, float width, float height,
Vector2 position) {
super(SPEED, rotation, width, height, position);
}
public void advance(float delta, Ship ship) {
if(rotation > 360)
rotation -= 360;
position.lerp(vect, delta);
rotation += delta * ROTATION_SPEED;
super.update(ship);
//Edited: i forget to put this lines:
if(vect.equals(this.getPosition())){
x = r.nextInt(36);
y = r.nextInt(24);
}
}
我应该在这个类中实现什么样的方法来让它们在一段时间后移动 x/y 值?