I have red a lot of materials at this moment but I still can't find the answer. I'm trying to do this -
http://i.stack.imgur.com/K7CSr.png
I don't have reputation to post pictures so i will try to explain. A side menu which will open on click (over the game screen) that has a text or buttons on it. It is supposed to be transparent or if it is not achiavable just some color. It needs to interact with the GameScreen. I did a research but i can't find something similar, some kind of table or something. Any idea on that question ?
Since it looks like you haven't tried anything, I will only give you a rough logic of how its going to work.
You want to draw 'something' when the button is pressed. You can use a boolean to check if you want to show panel or not. In your render() method, you can put an if statement which would draw the menu in case showMenu == true. Menu is nothing more than a bunch of images that act as buttons when clicked on specified coordinates so it should be exactly same as drawing any other game element. In your InputProcessor, you can check if showMenu == true then check if the user clicked on any buttons on menu, otherwise if showMenu is not true, just skip the check for menu buttons. When the user presses the show/hide button again, change the showMenu boolean again from true to false or false to true.
Related
Ok so I set up a method that takes the mousePressed argument and gets its point relative to the grid layout, and I want it to know that when I mouseRelease ( drop it ) it drops it in mouseRelease's targeted component but instead when I test it out it just says that I'm pressing and releasing on the same spot
Does mouseRelease and mousePressed not work the way I think it does? What should I do? Sorry I don't have pictures I'm on my phone rn lol
I'm using justTouched for manipulate easly touches and released in android, cause isTouched method acumulates many touches; but it works as the same in windows? Meaning, one event even when keep pressed? Or do I need another method/invoker/listener?
On desktop builds, Libgdx treats mouse button presses as touches. justTouched acts exactly the same, except that it polls mouse buttons instead of screen taps. And just like how on mobile you can't tell which finger just touched the screen, you can't tell which mouse button was just pressed. If you need to know which mouse button or finger touched down, you need to use an InputProcessor, which gives you far more information than using the Gdx.input convenience methods.
If you don't care which mouse button was just pressed, all you need is:
if (Gdx.input.justTouched()){
//...
}
Based on your comments under your question, you seem to be trying to distinguish which button just touched with || Gdx.input.isButtonPressed(Input.Buttons.LEFT)) which will return true on every frame as long as the left button is held down. And if instead you did && Gdx.input.isButtonPressed(Input.Buttons.LEFT)), then you wouldn't be sure that it's the left button that was just pressed. (Maybe you're holding down the left button and just pressed the right button.) There is no easy way to distinguish which button was pressed unless you are using an InputProcessor.
I am making a game. On the first screen, its just asking for all of the details but i don't want the actual game visible in the background. How do i set it so all the stuff in the back isn't visible and the opening bit, and as soon as the user presses play, it all becomes visible. I assume you would use "earnings.setVisible(true); but its already true, how do i get it so it starts off with false when i load the gui up. Or is there a better way of approaching this issue? New window maybe?
In my libgdx game, I have 2 screens, menu and list.
When I click on a label in the menu screen, I do a setscreen(list).
The new screen shows up, and the menu screen alongwith its labels disappears.
But when I click on the same positions (from menu screen where the labels were, but of course those labels are not showing as I have changed screens) the click event responds. Why?
note:My list screen currently has not event handlers for any widget.
When switching screens do I need to do anything more than just setscreen(anotherscreen) to deactivate oldscreen?
I changed this :
I moved the input processor to the show() method of that screen using stage variable of that screen
public void show() {
...
Gdx.input.setInputProcessor(stage);
}
before I was setting this only in the constructor of the screen, so even If I was changing the screen, the input processor was still attached to the last created screen's stage
The answer above adiddnt work for me because I dont work with a InputProcessor in the 2nd screen.
My Solution was to set the Inputprocessor to null after setScreen.
Gdx.app.getApplicationListener().setScreen(new Screen());
Gdx.input.setInputProcessor(null);
Just broke my head over this. I changed screens in the show method but had Gdx.input.setInputProcessor(stage) called after that. The method still completed after the show method of the new screen ran and thus reverting back to the previous stage.
So make sure you call Gdx.input.setInputProcessor(stage) before you change screens or return after you change screens.
Is there a way to make radio buttons do nothing when they are clicked? I am trying to make a Score Board and need a way to show the periods/halves/quarters ect. The radio buttons will be selected by the program to display periods/halves/quarters ect. Is this a good way to do it or is there a better way?
Check out the clickable attribute for Views
Defines whether this view reacts to click events.
Must be a boolean value, either "true" or "false".
http://developer.android.com/reference/android/view/View.html#attr_android:clickable
If the user doesn't ever need to click the radio buttons (ie if its always controlled by the program), why don't you just use images instead of radio buttons.
The benefits of using images for this are...
Images aren't clickable by default
It'll look nicer (you can make the Images look like a real scoreboard)
It doesn't rely on the default Android appearance (which is different for each phone)