Android specific touch problem

First, I’d like to say that I’m extremely pleased with tonegodGUI. It’s really user-friendly and is all around awesome.

I’m having this problem that is basically a focus issue I believe. When I run the basic start menu I’ve built to access specific levels in my game (which is just 2 buttons), on PC I can use the actionListeners in my other AppStates without a problem. However, on Android, I can’t click anything after my level is loaded using the button.

I’m detaching the state with the tonegodGUI and moving to another, where the actionListener for gameplay is located. Is there something the GUI does to hold focus of the mouse events?

I’m adding a listener to the inputManager in this separate state, but it doesn’t work well when I start the game using the tonegodGUI.

Any advice?

@Screamconjoiner said: First, I'd like to say that I'm extremely pleased with tonegodGUI. It's really user-friendly and is all around awesome.

I’m having this problem that is basically a focus issue I believe. When I run the basic start menu I’ve built to access specific levels in my game (which is just 2 buttons), on PC I can use the actionListeners in my other AppStates without a problem. However, on Android, I can’t click anything after my level is loaded using the button.

I’m detaching the state with the tonegodGUI and moving to another, where the actionListener for gameplay is located. Is there something the GUI does to hold focus of the mouse events?

I’m adding a listener to the inputManager in this separate state, but it doesn’t work well when I start the game using the tonegodGUI.

Any advice?

I’d need to take a look at how you are doing the switch between AppState(s). This is the way I handle things in my Android apps and don’t have any issues. Can you post the code for the two AppStates so I can help you narrow down the issue?

Thanks for getting back to me so quickly!

I solved this particular issue by setting setUseMultiTouch(false).

I’ve changed my code pretty significantly since I posted this last night, but I can still post if you would like me to.

My current problem is that I call setText() on buttons pretty frequently, and this task seems to be using the most amount of time out of any other in my entire project. It looks like each time setText() is called, a new BitmapText object is created, is there any way to avoid this by referencing say a button to an external BitmapText that gets updated in the update loop, rather than the button it’s self?

EDIT:
I read the wiki, and realized I was doing the one thing that you’ve said not to do… use panels as generic container. I added my buttons to the screen as an element rather than as a child on a panel and the difference is huge in terms of overhead.

Thank you so very much for this platform, it’s really quite freaking awesome.

1 Like
@Screamconjoiner said: Thanks for getting back to me so quickly!

I solved this particular issue by setting setUseMultiTouch(false).

I’ve changed my code pretty significantly since I posted this last night, but I can still post if you would like me to.

My current problem is that I call setText() on buttons pretty frequently, and this task seems to be using the most amount of time out of any other in my entire project. It looks like each time setText() is called, a new BitmapText object is created, is there any way to avoid this by referencing say a button to an external BitmapText that gets updated in the update loop, rather than the button it’s self?

EDIT:
I read the wiki, and realized I was doing the one thing that you’ve said not to do… use panels as generic container. I added my buttons to the screen as an element rather than as a child on a panel and the difference is huge in terms of overhead.

Thank you so very much for this platform, it’s really quite freaking awesome.

Alternatively, if you would like to group elements, you could always use the Element class and then call: Element.setAsContainerOnly(); This will remove any visual component (buffers) and give you the general layout functionality of nesting components.

As for the BitmapText issue, this one is a bit tricky as BitmapText (as well as the internal component TextElement) has to recreate it’s buffers to display the new String.

The only thing I can think of off the top of my head, would be to enqueue futures that build the new button label to offload the process to a new thread. Unfortunately, this will not stop the time it takes to update the buffers on the GPU, however repopulating/rebuilding the buffers will be handled in a background thread.

Though, since this is a relatively quick process, depending on the length of the string, it may take longer/use more resources to do it this way.

1 Like

Another thought… do you know the strings that will be used for text changes to the buttons?

If you do, perhaps you could pre-create Labels that you attach then hide/show depending on the button state? This would at least keep the time needed create the components bound to instantiation as apposed to dynamically creating them as you go.

I don’t know if this is a valid option for your use case or not, but it is worth considering maybe?

EDIT: Remember to .setIngoreMouse(true) on the Labels, if you go this route.

I’ll try the Element.setAsContainerOnly() option as soon as I get JME working again. Thanks for your suggestions, It’s awesome to have the creator of the plugin you’re using be able to direct you when you are trying to implement it in your own project :slight_smile:

1 Like