0

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?

4
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by llemes4011
0

Acegikmo,
getImage and getCodeBase are methods of Applet class.

Image image = new   ImageIcon("test.JPG").getImage();
...
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.