想做游戏的小白 2022-01-30 11:12 采纳率: 80%
浏览 110
已结题

为什么这段代码IDEA标红,运行时没报错。

问题遇到的现象和发生背景

public class Plane extends GameObject这句被IDEA标红

问题相关代码,请勿粘贴截图

GameObject类

package com.bjsxt;
import java.awt.*;
public class GameObject {
        /**
         * 对应的图片
         */
        Image img;
        int x,y;
        /**
         * 移动速度
         */
        int speed;
        /**
         * 物体的宽度,高度
         */
        int width,hejght;
        public GameObject(){}

    /**
     * 画自己
     */
    public void drawMyself(Graphics g){
        g.drawImage(img,x,y,width,hejght,null);
    }
    public Rectangle getRec(){
            return new Rectangle(x,y,width,hejght);
    }
    public GameObject(Image img, int x, int y, int speed, int width, int hejght) {
        this.img = img;
        this.x = x;
        this.y = y;
        this.speed = speed;
        this.width = width;
        this.hejght = hejght;
    }

    public GameObject(Image img, int x, int y, int speed) {
        this(img,x,y);
        this.speed = speed;
    }

    public GameObject(Image img, int x, int y) {
        this(img);
        this.x = x;
        this.y = y;
    }

    public GameObject(Image img) {
        this.img = img;
        if (this.img!=null){
            this.width= img.getWidth(null);
            this.hejght=img.getHeight(null);
        }
    }
}

Plane类:

package com.bjsxt;
import java.awt.*;
//下面那句被IDEA标红。
public class Plane extends GameObject{
    public static void main(String[] args) {
        System.out.println("111");
    }
}
运行结果及报错内容

IDEA标红理由:
Cannot access com.bjsxt.GameObject

我的解答思路和尝试过的方法

被气的没思路。

我想要达到的结果

我想让它不红。

  • 写回答

1条回答 默认 最新

  • Zl_? 2022-01-30 11:22
    关注

    这玩意儿经常卡,清下缓存重启试一下

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 2月12日
  • 已采纳回答 2月4日
  • 修改了问题 1月30日
  • 创建了问题 1月30日

悬赏问题

  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?