Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (579)
games submitted by our members
Games in WIP (500)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Best way to do a "overlay" (scores, info  (Read 1666 times)
0 Members and 1 Guest are viewing this topic.
Offline SpuTTer

Senior Member


Medals: 1


Lazy Middle Class Intellectual


« Posted 2004-03-09 06:32:39 »

Im working on my new game using Xith and Im wondering what the best way to make the game "overlay" is. Info such as scores, who's turn it is, etc.

Im currently messing with the Swing functions. Is that the best way? Im have some issues with the Swing functions rendering kind of weird, especially text (hard to read).

Basically looking for the best way to put 2D graphics and text on top of my game, that is not affected by the 3D transformations.

Thanks!

Sacramento Volleyball
"Whitty phrase goes here."
Offline kevglass

JGO Kernel


Medals: 85
Projects: 25


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #1 - Posted 2004-03-09 06:45:26 »

Theres a complete UIOverlay/UIWindow package in Xith, is that what you're playing with?

It allows you to "insert" swing windows as textures into the scene.

Kev

Offline Yuri Vl. Gushchin

Senior Member




Speak Java!


« Reply #2 - Posted 2004-03-09 07:17:04 »

Quote
Im have some issues with the Swing functions rendering kind of weird, especially text (hard to read).


Does Xith3DGuiTest work OK in your case?

Yuri

Yuri Vl. Gushchin
JProof Group
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline William Denniss

JGO Coder


Projects: 2


Fire at will


« Reply #3 - Posted 2004-03-09 10:09:33 »

Jens has a good tutorial on the topic as well:

http://xith.org/tutes/GettingStarted/html/integrating_swing.html

Will.

Offline SpuTTer

Senior Member


Medals: 1


Lazy Middle Class Intellectual


« Reply #4 - Posted 2004-03-09 16:14:06 »

Yes, when I reference Swing I was referring to the UIOverlay/UIWindow and my code is based on the GSG tutorial.

Yuri brings up a good point. The Xith3DGuiTest demo does and has always worked fine for me. The text looks very crisp. I'll do some further research to find out why my text is looking like its missing pixels.

My code was originally based on the GSG tutorial, I will check Xith3DGuiTest to see if I had anything wrong.

Thanks for the responses so far! Sounds like the UIOverlay/UIWindow is the way to go for my overlay?


Sacramento Volleyball
"Whitty phrase goes here."
Offline StefanD2

Senior Newbie




Java games rock!


« Reply #5 - Posted 2004-03-09 21:10:18 »

Yep. Go for UIWindow. I was inspired by this thread and added Swing to my simple 3d world. I love it! Especially the part that you can set your Swing components to be translucent and see the 3d-World behind it Wink

Take the example Jens created before and modify it a bit.

Disable the panel's opaqueness
1  
panel.setOpaque(false);


Set the textfield's background to white but use alpha settings (50% here):
1  
textfield.setBackground(new Color(1f,1f,1f,.5f);


And to make it work without showing that nasty window's background around your textfield do not forget to enable alphablending for your TestWindow:
1  
super(width, height, false, true)


Just one last note: add some 3D scenery - that will do it  Roll Eyes
Offline William Denniss

JGO Coder


Projects: 2


Fire at will


« Reply #6 - Posted 2004-03-10 00:53:12 »

thanks for that!  Grin

Maybe Jens should add some of that info to his tute.

Will.

Offline SpuTTer

Senior Member


Medals: 1


Lazy Middle Class Intellectual


« Reply #7 - Posted 2004-03-10 07:09:34 »

Ok, I got a chance to look and I've been messing with my code for a while. I started using the XithGuiTest code and it was working perfectly, but then, it started showing the same "artifacting" that I had with my own code. I traced the problem to an issue when I set the Width of the panel.

If I keep the width at 100, which is what they are using the demo, it looks great. If set the width to say, 150, it starts to look skewed. I have prepared an image that shows what Im talking about.

Here is some code just showing what "width" Im talking about..

1  
2  
3  
4  
5  
...
            JPanel p = new JPanel();
            p.setDoubleBuffered(true);
            p.setSize(new Dimension(width,height));
...


Thanks for your help!

Here is the image showing the problem:

http://www.fightcompany.com/sputter/swing_gui_issue.jpg

Sacramento Volleyball
"Whitty phrase goes here."
Offline StefanD2

Senior Newbie




Java games rock!


« Reply #8 - Posted 2004-03-10 17:31:40 »

@SpuTTer: That is quite strange. I experienced such behaviour in Swing with outdated Java-versions only ... For me it does not depend upon width even with the string you are using... Which OS, Java version and font are you using? My configuration is Windows 2000, Java 1.4.2_03 and default font.
Did you tested  this with a simple Java-Swing-App without using xith also? Are you usiong absolute positioning or a LayoutManager?

@William Denniss:
Regarding the input field (and thinking of additions to Jens' tutorial) we also do need some text regarding editable textfields! This is because a key listener added to the canvas (used for navigation as e.g. in JCD's demos) will be influenced by key input for  the textfield also - just because of the UIEventAdapter. Same goes for mouse listeners.

Otherwise we would edit text and move around - btw. nice effect Wink





Offline SpuTTer

Senior Member


Medals: 1


Lazy Middle Class Intellectual


« Reply #9 - Posted 2004-03-10 18:21:59 »

Im on Windows XP, 1.4.2-b28. Im using the default font, but I've tried Serif size 12 also.

Im using the default layout right now but I also tried it with BoxLayout and got the same result.

My last ditch thought was to re-create a simple Swing app and see if it does the same thing.

Maybe I'll try that tonight. Hopefully I can track this down.

Sacramento Volleyball
"Whitty phrase goes here."
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline StefanD2

Senior Newbie




Java games rock!


« Reply #10 - Posted 2004-03-10 19:49:22 »

Using 1.4.2_03-b02 here - currently 1.4.2_04 is out. Your version is a bit dusty I believe. Though it is not that old installing a newer JDK may be a quick solution as I found some problems in Sun's bugparade that do not exactly match your problem but are somewhat related to it known for at least 1.4.x: 4866495 (Fonts of some Components look worse in 1.4.2 vs 1.4.1),  4840307, (TextField characters unreadable),
4924220 ( Microsoft Sans Serif (True Type) font is not rendered properly). I neither can guarantee that I found your bug nor that the latest version will help but I would give it a try also ...
Offline SpuTTer

Senior Member


Medals: 1


Lazy Middle Class Intellectual


« Reply #11 - Posted 2004-03-10 19:53:21 »

I will install 1.4.2_04 tonight and hopefully that'll clear things up, pun intended!

Thanks for your time. I'll let you know how it works out.

Sacramento Volleyball
"Whitty phrase goes here."
Offline SpuTTer

Senior Member


Medals: 1


Lazy Middle Class Intellectual


« Reply #12 - Posted 2004-03-16 05:48:41 »

I finally figured this out... this strange occourance only happens in windowed mode. If I set my canvas to full screen, the text looks fine... Is this a bug?

A quick change from

1  
2  
3  
//CanvasPeer cp = rp.makeCanvas(null, 800, 600, 16, false);

CanvasPeer cp = rp.makeCanvas(null, 800, 600, 16, true);


and the text is perfectly clear.

Sacramento Volleyball
"Whitty phrase goes here."
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (31 views)
2014-04-15 18:08:23

BurntPizza (28 views)
2014-04-15 03:46:01

UprightPath (43 views)
2014-04-14 17:39:50

UprightPath (26 views)
2014-04-14 17:35:47

Porlus (42 views)
2014-04-14 15:48:38

tom_mai78101 (64 views)
2014-04-10 04:04:31

BurntPizza (124 views)
2014-04-08 23:06:04

tom_mai78101 (224 views)
2014-04-05 13:34:39

trollwarrior1 (190 views)
2014-04-04 12:06:45

CJLetsGame (198 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!