This is my first post
I read through the tutorials and i ran across HUD’s and Nifty as a way to create a user interface for games. However, is it possible to directly draw on the game Canvas via its graphics (Graphics2D) ? I would like to stay away from Nifty because it doesent seem very appealing and user friendly.
This is my first post
[java]I would like to stay away from Nifty because it doesent seem very appealing and user friendly.[/java]
I don’t agree :D.
Btw such stuff can be found in jME3 Tests project. Create it and look for “canvas” by pressing “ctrl+shift+f”.
Thanks for the reply :). I found an example laying on the internet somewhere on how to grab the Canvas and place it on a GUI.
This is how I captured the Canvas:
Main canvasApplication = new Main();
JmeCanvasContext ctx = (JmeCanvasContext) canvasApplication.getContext();
Dimension dim = new Dimension(640, 480);
But now, whenever i draw directly to the Canvas (ctx.getCanvas().getGraphics().drawString(“hello world”,10,10)) It shows on the canvas until i see the game. I heard i could make use of GlassPanes (Have the game render to the canvas but have this transparent invisble layer draw my HUD), but i tried it and it wouldnt work? Can someone lead me in the right direction? Thank you!
You cannot draw on the canvas as the hardware draws on it. You can use awt panels instead of the canvas, theres tests for it. Mind that you have to care about threading issues between AWT and the OpenGL thread, so the few issue you have getting into nifty now might be dwarfed by the issues you get when you mix AWT and the OpenGL output. Its not like we tell you do to stuff in a certain to annoy you but because we know better about the implications.
Okay i see…Thank you. It just seems that i will need to learn XML just to get nifty working. Unless theres another way?
Whats there to learn about XML :roll: its opening tag, closing tag and tag attributes… Maybe you try to imagine your UI and impose it onto your game by sheer willpower, that might be easier.
Now I know when he said “I would like to stay away from Nifty because it doesent seem very appealing and user friendly.”.
Lol. xml are our best friends. This improves the maintenance.