XNA Creators Club Online
Page 1 of 1 (4 items)
Sort Posts: Previous Next

Locking Frame Rate In 2D Tile Engine

Last post 9/21/2009 8:43 PM by Daniel Hanson. 3 replies.
  • 9/17/2009 11:32 PM

    Locking Frame Rate In 2D Tile Engine

    I'm curious as to what is the best (easiest?) way to lock the framerate in a 2d side-scroller using a tile engine.  Ideally, I would like to lock both the Update() and Draw() methods at 30 updates a second.  Any suggestions?  Thanks in advance.
  • 9/17/2009 11:54 PM In reply to

    Re: Locking Frame Rate In 2D Tile Engine

    Answer
    Reply Quote
    The frame rate, by default, is already locked at 60 fps. No extra work is required.
    Previously known as "Rainault".
    Twitter - me, Jade Vault Games
    Announcing ASCII Quest, a Roguelike under development for Xbox LIVE Indie Games
  • 9/21/2009 12:16 PM In reply to

    Re: Locking Frame Rate In 2D Tile Engine

    You can change this by changing the Game.IsFixedTimeStep and Game.TargetElapsedTime in the Game() constructor.

    To set the game to 30fps, do this in the game constructor:

    this.TargetElapsedTime = new TimeSpan(0, 0, 0, 0, 32);
    Graphics Programmer,Sandswept Studios.http://www.sandswept.net
  • 9/21/2009 8:43 PM In reply to

    Re: Locking Frame Rate In 2D Tile Engine

    I would prefer this, as it is more readable.

    this.TargetElapsedTime = TimeSpan.FromSeconds(1.0 / 30.0);
    Previously known as "Rainault".
    Twitter - me, Jade Vault Games
    Announcing ASCII Quest, a Roguelike under development for Xbox LIVE Indie Games
Page 1 of 1 (4 items) Previous Next