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

Locking Frame Rate In 2D Tile Engine

Last post 21/09/2009 20:43 by Daniel Hanson. 3 replies.
  • 17/09/2009 23:32

    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.
  • 17/09/2009 23:54 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
  • 21/09/2009 12:16 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
  • 21/09/2009 20:43 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