I am currently writing a weapon class and a projectile class, to use in a top-down game.
However, I can't seem to be able to load images in a class. It works in the main function, where I do it like this:

Image bulletImage =getImage(getCodeBase(),"bullet_machinegun.png");

However, this doesn't work inside the projectile class.
It can't find the getImage and the getCodeBase methods.
And passing an image object through constructors and such seems extremely tedious.

Is there a way of loading images inside classes?

Acegikmo,
getImage and getCodeBase are methods of Applet class.

Image image = new   ImageIcon("test.JPG").getImage();
...
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.