Java 类的实例赢得';t运行重写的方法

Java 类的实例赢得';t运行重写的方法,java,class,methods,lwjgl,game-engine,Java,Class,Methods,Lwjgl,Game Engine,我有一个包和两个类: AbstractEntity 实体(实现了抽象实体) 播放器(扩展了实体) 我有一个名为move()的公共void方法。在实体中声明为空方法,在实体中声明为空方法,在玩家中再次声明为玩家的实际移动方法。但是,当我在主循环中调用此代码时: for(Entity entity:allEntities){ entity.move(); renderer.processEntity(entity); } move方法在实体类中实现: @凌驾 公开作废动议(){ }

我有一个包和两个类:
AbstractEntity
实体
(实现了
抽象实体
播放器
(扩展了
实体

我有一个名为move()的
公共void方法。在
实体
中声明为空方法,在
实体
中声明为空方法,在
玩家
中再次声明为玩家的实际移动方法。但是,当我在主循环中调用此代码时:

for(Entity entity:allEntities){
    entity.move();
    renderer.processEntity(entity);
}
move方法在实体类中实现: @凌驾 公开作废动议(){ }

在玩家类中为:

@Override 
public void move(){

    checkInputs();
    rotY += currentTurnSpeed * DisplayManager.getFrameTimeSeconds();
    float distance = currentSpeed * DisplayManager.getFrameTimeSeconds();

    float dx = (float) (distance * Math.sin(Math.toRadians(rotY)));
    float dz = (float) (distance * Math.cos(Math.toRadians(rotY)));

    upwardsSpeed+= Gravity * DisplayManager.getFrameTimeSeconds();
    float dy = upwardsSpeed * DisplayManager.getFrameTimeSeconds();

    if(super.getPosition().y<TerrainHeight){
        upwardsSpeed = 0;
        dy = TerrainHeight - super.getPosition().y;
    }

    super.increasePosition(dx, dy, dz);
    super.setRotation(new Vector4f(0f,(float) (Math.sin(Math.toRadians(-rotY/2))),0f,(float) Math.cos(Math.toRadians(-rotY/2))));

    System.out.println("here");


}
@覆盖
公开作废动议(){
检查输入();
rotY+=currentTurnSpeed*DisplayManager.getFrameTimeSeconds();
浮点距离=currentSpeed*DisplayManager.getFrameTimeSeconds();
float dx=(float)(距离*Math.sin(Math.toRadians(rotY));
float dz=(float)(距离*Math.cos(Math.toRadians(rotY));
upwardsSpeed+=Gravity*DisplayManager.getFrameTimeSeconds();
float dy=upwardsSpeed*DisplayManager.getFrameTimeSeconds();

if(super.getPosition().y结构应该如下所示:

Player extends Entity
Entity extends AbstractEntity
您所指的实例应该是调用Player方法的
Player


Entity Entity=新玩家()

我发现了我的错误,这只是一个隐藏在代码折叠中的问题。玩家实体从来没有被添加到实体列表中,也没有被处理和呈现,而是单独呈现。我现在也将其添加到了Allenties数组中,并按预期运行。几个小时的挫折本来可以避免的如果我刚刚打开我的代码折叠。

你确定你正在调用方法的实际对象是Player类而不是实体吗?请包括
实体
类和
播放器
类的相关代码(即在这两个类中实现
移动()
)。两个实现都添加了,调用该方法的实体是从实体数组中提取的,但添加为玩家类。请在问题的末尾将其添加为编辑部分