问题遇到的现象和发生背景
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
我的解答思路和尝试过的方法
被气的没思路。
我想要达到的结果
我想让它不红。