How to limit fps on android

I have limited the fps on the desktop to 30fps but on android I get 60fps. I want it locked because my game needs more stuff.

Just to be sure, what approach did you use to limit FPS on desktop and where did you set this up?

OGLESContext looks like a promising start:


Maybe someone knows a bit more about this, however there is a line at the top that was commented out that set the FPS to a max of 33 frames per second.

EDIT: More specifically, have a look at applySettings(AppSettings settings);

Count the ms from update to update and sleep for an additional time if necessary?

@pspeed said: Just to be sure, what approach did you use to limit FPS on desktop and where did you set this up?

The reason I asked this question is because the normal approach would be to set the frame rate on AppSettings in the main() method.

The main() method is not run on Android as that’s only run on desktop.

On Android you do it in a different place. I’ve never done android development but I think it’s done in the harness. I’m presuming (perhaps erroneously) that setting the frame rate will work on Android (and I see no reason why not) and would avoid manually coding the same sleep delay as suggested.

This also presumes that the other things that the game is doing are done on a different thread… otherwise this will do nothing but slow the whole game down.

Have anyone solved this problem? I’m trying to limit fps on android, but it’s like android overwrites that setting. I set the framerate with the code:

    public void onCreate(Bundle savedInstanceState){
        AppSettings appSettings = ctx.getSettings();

in my activity. Any idea??

See my post above, its a bit rough approach but works perfectly.

I’ll try to sleep. I was looking to a method more clean and considering that JME offers this method, I was trying to use it. Despite that, Android continue to run at its framerate, ignoring the parameter setted by me. :weary: