00:00
00:00
Newgrounds Background Image Theme

ParallaxDraw just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

tracing frame render time

710 Views | 5 Replies
New Topic Respond to this Topic

tracing frame render time 2012-05-18 20:09:30


Im trying to set up responsive quality controls in my game (so that when it gets laggy the quality automatically steps down for a bit)

I tested the frame rate, and it stays where its supposed to be the whole time, so Im wondering if there's a way to trace the time it takes for flash to render each frame?

(sorry if thats a stupid question, if it is, just ignore it and point me in a better direction!)

Thanks!
(this should be the last question I have to ask for awhile :o)


BBS Signature

Response to tracing frame render time 2012-05-18 21:52:26


you'll have to wright your own method of getting the fps, this is the one i use.

private var prevtime:int = 0;

		private function update(e:Event):void {
			var time:int
			
			//show text on screen
			
            time = getTimer();
			
			if(delay.expired){
				delay.reset(10);
				fps = 1000 / (time - prevTime); delay.reset(10);
			}
			//
            
			prevTime = getTimer();
			
			update()
		}

Response to tracing frame render time 2012-05-18 22:01:23


negate the "update()" at the end of my code, something from what i was making and forgot to cut out when i made the post.

Response to tracing frame render time 2012-05-19 16:27:25


At 5/18/12 08:09 PM, blakemoso wrote: Im trying to set up responsive quality controls in my game (so that when it gets laggy the quality automatically steps down for a bit)

I tested the frame rate, and it stays where its supposed to be the whole time, so Im wondering if there's a way to trace the time it takes for flash to render each frame?

(sorry if thats a stupid question, if it is, just ignore it and point me in a better direction!)

Thanks!
(this should be the last question I have to ask for awhile :o)

you, my good sir, have a brilliant idea. Auto-quality control. I like it. Just make sure to allow a user override


Programming stuffs (tutorials and extras)

PM me (instead of MintPaw) if you're confuzzled.

thank Skaren for the sig :P

BBS Signature

Response to tracing frame render time 2012-05-19 16:56:34


This thread inspired me to try making a quality adjuster as well.
Here it is:

import flash.utils.getTimer;

var curTime:int = 0;
var prevTime:int = 0;
var diffTime:int = 0;
var fps:int = 0;

private function adjustQuality():void
		{
			prevTime = curTime;
			curTime = getTimer();
			diffTime = curTime - prevTime;
			
			fps = int((1 / diffTime) * 1000);

			if(fps <= (stage.frameRate - 10))
			{
				stage.quality = StageQuality.LOW;
			}
			else if(fps > (stage.frameRate - 10) && fps <= (stage.frameRate - 5))
			{
				stage.quality = StageQuality.MEDIUM;
			}
			else
			{
				stage.quality = StageQuality.HIGH;
			}
		}

I implore you to reconsider.

Response to tracing frame render time 2012-05-19 17:10:38


At 5/19/12 04:56 PM, Khronosis wrote: This thread inspired me to try making a quality adjuster as well.
Here it is:

import flash.utils.getTimer;

var curTime:int = 0;
var prevTime:int = 0;
var diffTime:int = 0;
var fps:int = 0;

private function adjustQuality():void
{
prevTime = curTime;
curTime = getTimer();
diffTime = curTime - prevTime;

fps = int((1 / diffTime) * 1000);

if(fps <= (stage.frameRate - 10))
{
stage.quality = StageQuality.LOW;
}
else if(fps > (stage.frameRate - 10) && fps <= (stage.frameRate - 5))
{
stage.quality = StageQuality.MEDIUM;
}
else
{
stage.quality = StageQuality.HIGH;
}
}

I see two issues with that code (though I don't actually know AS3. Just AS2)

1.the millisecond the FPS drops to 10, it switches the quality to low. So if a player's fps drops to 2 and then goes back to 30, it's going to confuse the hell out of them because all of a sudden they lost quality for a quarter of a second

2. Once you reduce the quality, the FPS is going to go back up. It's going to constantly switch between "HIGH" and "LOW" and annoy the hell out of the player.


Programming stuffs (tutorials and extras)

PM me (instead of MintPaw) if you're confuzzled.

thank Skaren for the sig :P

BBS Signature