Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (524)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (592)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Limiting libgdx frame rate?  (Read 5396 times)
0 Members and 1 Guest are viewing this topic.
Offline wreed12345

JGO Knight


Medals: 25
Projects: 2
Exp: 2 years


http://linebylinecoding.blogspot.com/


« Posted 2012-12-31 21:32:42 »

Is there such a way to limit the libgdx frame rate?

Offline cheatsguy

Junior Devvie


Medals: 3


Gamer turned Pixel Artist turned Programmer


« Reply #1 - Posted 2012-12-31 21:50:58 »

I had this issue before, and there is a backend in LWJGL that lets you do this, but I'm not 100% sure where it is. quick google search turned up this:
http://code.google.com/p/libgdx-users/wiki/limitFps
if you have any general questions about LibGDX this is a very helpful source.

Busy between school, work, life, games, programming and general screwing around.
If you'd like some pixel art for your game, send me a PM, i'll see what I can do.
Current project: http://elementalwarblog.wordpress.com/
Offline wreed12345

JGO Knight


Medals: 25
Projects: 2
Exp: 2 years


http://linebylinecoding.blogspot.com/


« Reply #2 - Posted 2012-12-31 21:55:06 »

thanks do you know how to make frame independent movement? I am using this code but its not working Sad
1  
2  
      if (X < 300)
         X += .05f * Gdx.graphics.getDeltaTime();

I thought this would work correctly but it isnt... any ideas?

X is the x cordinate of the character

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline cheatsguy

Junior Devvie


Medals: 3


Gamer turned Pixel Artist turned Programmer


« Reply #3 - Posted 2012-12-31 21:58:11 »

I'm not sure exactly what you're trying to accomplish? I am assuming that your X is the x position of your character, so going on that, I'd say to avoid using deltaTime to move around on the screen, and instead simply add/subtract in the logic. this works for me, but I'm not sure if its exactly accurate all the time. perhaps someone more experienced with LibGDX can help.

Busy between school, work, life, games, programming and general screwing around.
If you'd like some pixel art for your game, send me a PM, i'll see what I can do.
Current project: http://elementalwarblog.wordpress.com/
Offline ReBirth
« Reply #4 - Posted 2012-12-31 23:39:52 »

That code looks like you're going to move thing in one direction. See if Actions classes provide what you need.

Offline LunaticEdit

Senior Devvie


Medals: 8
Projects: 1



« Reply #5 - Posted 2012-12-31 23:50:01 »

I use the physics engine for motion, but I do time based animation and it is smooth on both android phone and desktop:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
    private boolean processAnimation() {
        if (_animationSpeed == 0) {
            return false;
        }

        if (!_animate) {
            return false;
        }

        final double timeDiff = System.currentTimeMillis() - _lastTime;
        if (timeDiff < _animationSpeed) {
            return false;
        }

        _lastTime += _animationSpeed;
        if ((++_currentFrame) >= _totalFrames) {
            _currentFrame = 0;
        }
        return true;
    }


It ++s to ensure that if a frame gets skipped due to time delay it will keep incrementing frames until we get to where we are supposed to be (I guess the 'tunnel' effect, but with animation).

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

toopeicgaming1999 (51 views)
2014-11-26 15:22:04

toopeicgaming1999 (44 views)
2014-11-26 15:20:36

toopeicgaming1999 (8 views)
2014-11-26 15:20:08

SHC (24 views)
2014-11-25 12:00:59

SHC (24 views)
2014-11-25 11:53:45

Norakomi (26 views)
2014-11-25 11:26:43

Gibbo3771 (23 views)
2014-11-24 19:59:16

trollwarrior1 (36 views)
2014-11-22 12:13:56

xFryIx (75 views)
2014-11-13 12:34:49

digdugdiggy (52 views)
2014-11-12 21:11:50
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!