A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: [F8] Actual Frame Rate

  1. #1
    Humble Flash Newbie
    Join Date
    Feb 2007
    Posts
    107

    [F8] Actual Frame Rate

    Hi!

    Is there an easy way to monitor the actual frame rate of the game? Of course, when it drops badly, it's obvious, but I want to be able to make quantitative comparisons. I want my baddies to animate, slightly, but not if it messes up the frame rate too much. ( Do you reccon it does?)

  2. #2
    Hype over content... Squize's Avatar
    Join Date
    Apr 2001
    Location
    Lost forever in a happy crowd...
    Posts
    5,926
    Here's my as3 one ( Not sure what language you're developing in )

    http://blog.gamingyourway.com/PermaL...b269bbe2e.aspx

    My as2 one has been floating around the board for ages now, I'm sure a search will bring it up ( I think it may be in my template.fla ).

    Squize.

  3. #3
    Humble Flash Newbie
    Join Date
    Feb 2007
    Posts
    107

    Lightbulb Cute solution

    Thanx Squize, but I code AS2, so I couldn't open that.
    Anyways, I thought about it, and it turned out to be easy to make my own minimalistic one. Like this:

    Create a text field in your game with the name fpsBox. (Since I think trace() might ruin fps itself)

    declare these globals
    Code:
    var frameCounter:Number = 0;
    var my_date:Date = new Date ();
    var my_time = my_date.getTime ();
    paste this function:
    Code:
    function fpsTester() {
    	frameCounter++;
    	if (frameCounter%10 == 0) {
    		var my_date2:Date = new Date ();
    		fpsBox.text= (Math.round(1000000/(my_date2.getTime () - my_time))/100);
    		my_date= new Date ();
    		my_time = my_date.getTime ();
    	}
    }
    and call it with fpsTester(); from within a this.onEnterFrame function.

    This will keep you posted about the fps every 10 frames. You get a more accurate number if increasing this, but the result less often. The million I divide with time is for 1000 miliseconds, 10 frames and 100 for 2 decimals.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center