问题描述
我正在使用此代码尝试绘制图像:
I'm using this code to try and draw an image :
g.drawImage(Tile.background, (int)spritePositionX, (int)spritePositionY, null);
这是Tile.background的我的tile类:
Here is the my tile class for 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)
提前致谢
It gives me this error :The method drawImage(Image, float, float, Color) in the type Graphics is not applicable for the arguments (BufferedImage, int, int, null)Thanks in advance
这些是我在g.drawImage所在的类中的导入:
These are my imports in the class that the g.drawImage is in :
import javax.swing.ImageIcon;
import org.lwjgl.input.Mouse;
import org.newdawn.slick.*;
import org.newdawn.slick.state.*;
import java.awt.Rectangle;
推荐答案
您正在尝试使用Slicks实现图形没有方法的对象,你提供的参数。无论如何,光滑已经死了。切换到LIBGDX或只使用Java的2d API。
You're trying to use Slicks implementation of the Graphics object which doesn't have a method with the arguments you're providing. Slick is dead anyway. Either switch to LIBGDX or just use Java's 2d API.
这篇关于无法绘制缓冲图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!