Eclipse 说我不能对非静态字段 Art.instance 进行静态引用。为什么它认为我是从静态上下文中调用 Art.instance ?
TDRenderer 本身的调用方式如下:
renderer = new TDRenderer();
TDRenderer.java:
package towerDefense;
import java.awt.Graphics;
import java.awt.Image;
public class TDRenderer {
public Art art;
public TDRenderer()
{
art = Art.instance;
}
public void render(Graphics g)
{
for(int i = 0; i < 32; i++)
{
for(int j = 0; j < 24; j++)
{
Image itd = (Image)(art.sprites[art.level1.tiles[i][j].type]);
g.drawImage(itd, itd.getWidth(null), itd.getHeight(null), null);
}
}
}
}