Eclipse says I can’t make a static reference to the non-static field Art.instance. Why does it think I’m calling Art.instance from a static context?
TDRenderer itself gets called like so:
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);
}
}
}
}
It’s not that you’re in a static context; it’s that
instanceis not a static field ofArt, but referencing it asArt.instancemeans you’re trying to use it as if it were static.