我正在尝试制作运动的游戏,但是现在它说:“游戏无法解决或不是字段”

  • 本文关键字:游戏 解决 字段 运动 java
  • 更新时间 :
  • 英文 :


您好,我正在尝试创建一个游戏。这个游戏的动作一直效果,直到我开始动画为止。我不知道为什么,但是现在显示了这个错误:"游戏无法解决或不是字段。(对不起,如果这是一个愚蠢的问题,我是编程的新手。)

package hra2.entities.creatures;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import hra2.Game;
import hra2.gfx.Animation;
import hra2.gfx.Assets;
public class Player extends Creature {
//ANIMATIONS 
private Animation animLeft;
private Animation animRight;
public Player(Game game, float x, float y) {
    super(x, y, 53, 79);
    this.game = game;
    //ANIMATIONS
    animLeft = new Animation(500, Assets.hrac_left);
    animRight = new Animation(500, Assets.hrac_right);
}

public void tick() {
    //ANIMATIONS
    animLeft.tick();
    animRight.tick();
    //MOVEMENT
    getInput();
    move();
}
private void getInput() {
    xMove = 0;
    float nula = 0;
    float tisic = 920;
    if(game.getKeyManager().left)
        xMove = -speed;
    if(game.getKeyManager().right)
        xMove = speed;
    if(x <= nula) {
        x += 5;
    }
    if(x >= tisic) {
        x -= 5;
    }
}

好吧, game不是您类的字段。使gameanimLeftanimRight

一样

它在 this.game = game; ,您的同类中没有游戏变量。

最新更新