Background images
Hello. I am currently working on a soccer manager game.
I wonder if there's a way i can put a background image to a
component and then add transparent components on top of this.
is there support for such in the java language ?
also, if u have any suggestions for creating a game engine i'd love
to hear from u. i am working on a engine simulating a match.
this engine has to consider each team's tactical dispositions,
each player's skills, form, etc...
thanks.
Hey generalsnus,
I am doing my final year project and decided to do a soccer managemant game. However with a week left I still have no idea on how to create the game engine in order to simulate the matches. I have just come accross your post and was wondering did you figure anything out!?
Or anybody else for that matter? I am in desperate need for help as the deadline is May 4th and im only a newbie to the language. Im in way over my head and could do with a few pointers on the match engine.
Thanking you in advance
[quote]
I am doing my final year project .... <snip>..... However with a week left I still have no idea on how to create the game engine...<snip>...Im in way over my head...<snip>
[/quote]
Indeed you are, I won't say anything else 'cos im sure it'll depress you still further ^_^
Goodluck anyhow :D
Abusea at 2007-7-11 22:12:54 >

Subclass your background component and override its public void paint(Graphics g) method to make it paint the background image. Then, I believe you can setOpaque(false) on the other components, or just try drawing them and see what it looks like. Take a look at http://java.sun.com/docs/books/tutorial/uiswing/14painting/index.html and maybe http://java.sun.com/docs/books/tutorial/2d/index.html for more information.
Mateia at 2007-7-11 22:12:54 >

If the image covers the component's whole area, then it could be an idea to subclass update() and replace it's background color fill with the image rendering. (At least this works in AWT, I don't know if you're supposed to do that with swing components, given their pane structure...)