I would like to achieve the following behavior:
Draw a scrollable world map of x*y tiles. Draw a given part of this map inside a dialog window (using the class Dialog). Pretty much the way Transport Tycoon enabled you to see a little part of the world inside a dialog window: https://wiki.openttd.org/images/7/76/Speed-limits.png.
You can be anywhere on the map, but still see the train, plane or any object inside the dialog window.
I am currently clueless about a smart way to achieve this. My current thought can be broken down to using two stages: one for the world and for the UI. I can then draw the Map onto the world stage. But according to this: Is it possible in LibGDX's `scene2d` API to have the same Actor instance in multiple Stages? I cannot simply add the Map or any Actor to another stage because it will be removed from the previous stage.
So I am wondering: What is the most intelligent way to solve this? Is there one? Do I miss something essential here? Thank you for any answer!
Related
I am trying to get something like this:
I want a UI windows and in the center of window I want to display my world.
I want to use scene2D and scene2D.ui with an Orthographic camera.
Any advice?
Edit: I know that I must use two stages in order get a ui and world windows but I don't know how I can tell to the world window stage that render its content in that section instead all screen.
There are two ways you can go about.
Use a CustomViewPort for the stage responsible for rendering world. It is fairly easy to use and example is given in the wiki.
Let it be rendered on entire screen. This way you could keep UI backgroundless and space between components would be filled by world itself. It might be considered more immersive by many. You would also be allowed to use semi-transparent UI this way.
Anyways, it's a matter of taste.
Hope it helps.
For my Comp Sci assignment, I have to make a world that has Village objects connected via Roads in a graph data structure.Gnomes, each running their own thread traverse this world from one village to another using the shortest path. This whole thing needs to have a GUI, however.
Basically I need to have a grid with the villages on the intersections. Something like this ( without the numbers):
(source: kwiznet.com)
The villages have to be interconnected with roads. If it is not too difficult, roads should be deletable if they are not the only road connecting the village to the rest of the graph. This would be done via clicking.
There must also be an option to add villages by clicking on the graph, and select current villages, deleting them.
Basically:
Graph data structure is translated to GUI grid
Roads and Villages can be selected
Selected items can be deleted
Could you please just point me to what I need to research as I am new to GUIs? Such as the best layout manager, in what way to handle action events, how to draw a grid, etc. I just need a brief outline.
This is a HUGE question, although that's not really your fault. Here goes:
Read through the Java Swing Tutorial.
Learn a bit about MVC. Link1 Link2
Understand that Swing is not thread safe.
Then:
The best layout manager for your graph is likely the grid layout.
Probably you should add a JButton to each node so you can just click on it. JButtons can be made to look like anything so don't be put off by how they look by default.
Then MOST IMPORTANT: probably you should use a GUI Builder tool of some sort. I recommend NetBeans Matisse if you are new.
Now you should try all of that, and ask a SPECIFIC QUESTION when you get stuck. Good luck!
I am attempting to create a a java GUI for use on Zedboard with the 7" touchscreen display. The GUI I am creating is supposed to mimic exactly (though scaled down) a physical console with many interactive buttons.
My question is what would be the best method in making the buttons interactive, my first thought was to cut out the buttons of the console and have each one a separate image that can be set as interactive, but I feel there may be another simpler method.
Thanks
LDY
For the console mimicking, you could take an image of the entire console and then listen to touch event at specific points in the image which corresponds to a button. Based on where the touch event occurs, you could do different actions.
For this you need to get the coordinates of the touch event and check if it corresponds to any of the buttons on the console.
I have been making a video using pure Java. I would like to put in a pop-up menu for players when every they hit ESC. I have the menu setup but it looks really quite ugly. I would like to make the menu blur the image behind it.
For example on the new iOS 7 on Apple devises a lot of the things like the dock blur to whatever is behind it. There is an example of what I am trying to achieve below!
The simplest solution would be to use something JXLayer, as it will allow you to apply filter effects to the components that it covers.
For example.
I have a screen in my LibGDX game that will be essentially two columns, the first being 75% of the real estate and containing labels/buttons, and the next being 25% that will contain text and images. It is pretty complicated to include all of the code directly in the screen itself for this.
What I would like to do is to have one object contain the logic for the left side of the screen, and one for the right. This would be similar to ASP.NET, where I have a page, with one user control for the left content, and one for the right.
How can this be setup in a LibGDX screen?
I recommend you use scene2D and create new class for each element.
For example, you can create one class that extends Group for each side. Then you can add a ClickListener to group or to each Actor of the group with your logic.
Actually there are alot of ways you could do this. You can handle the events yourself by checking the if something is touched and if so, you do handle it yourself by the position.
On the other side you can use the scene2D system by creating Actors inside of a Stage and set the inputprocessor to the stage. In that case every event is given to the actors and if its inside of his bounds he does handle it depending on the implemented way (Take a look at this: ActionListenes).
So in your case you could create 2 Actors which are invisible
and everyone of it has its side.
You could also use the Button
from libgdx and use this without a background/foreground or such. Simply set the right sizes and make it invisible by the alpha or no background.
or you do check in every cycle of the gameloop if something is touched and if so you do handle the event as you whish. Take a look at this: input polling and creating an input processor