我正在使用此代码尝试绘制图像:
g.drawImage(Tile.background, (int)spritePositionX, (int)spritePositionY, null);
这是我的 Tile.background 瓷砖类:
public class Tile {
public static int size = 40;
public static BufferedImage terrain, background, items, characters;
public Tile(){
try{
Tile.background = ImageIO.read(new File("res/bg.png"));
Tile.terrain = ImageIO.read(new File("res/terrain.png"));
Tile.items = ImageIO.read(new File("res/items.png"));
Tile.characters = ImageIO.read(new File("characters/bg.png"));
}catch(Exception e){
System.out.println("Error loading images.");
}
}
}
它给了我这个错误:Graphics类型中的方法drawImage(Image,float,float,Color)不适用于参数(BufferedImage,int,int,null)提前致谢
这些是我在 g.drawImage 所在的类中的导入:
import javax.swing.ImageIcon;
import org.lwjgl.input.Mouse;
import org.newdawn.slick.*;
import org.newdawn.slick.state.*;
import java.awt.Rectangle;