Sign in to follow this  
prof_89

loading images in java

Recommended Posts

prof_89    122
Hi, im working on a game and for the moment my main class is flooded with "image-loading-code"... how can i load the images in a seperate class (imageload.class) ??

Share this post


Link to post
Share on other sites
rasher_b2    128
You would need to make a separate class like you've suggested. You could have a method such as getImage(imageName). It would be handy to store the images so they don't have to be loaded every time. You could use a hash map for this, using the image's path/name as a key. That way, when you request an image from the class it will look up the hash map and return the image. If the image hasn't been loaded then go ahead and load it.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this