I've created a thing that measures the frame rate of my game and if it is below a certain level it lowers the game quality until the fps is to a non laggy level.
Only problem is that I cannot figure out how to test it. How can I stimulate lag?
Wait, you realize the possible flaw in this? If you lower the quality, it will raise the FPS, which will raise the quality, which will l lower the FPS, which will lower the quality, ect. You may be creating a disorienting infinite loop.
Either way, just open a lot of programs and then run the game.
For the purposes of testing if your utility works could you create a quick sprite of a png file and generate 100-200 of them and make them move every frame?
Forcing Flash player to lag sounded like something that could be useful so I threw this together. It draws a specified amount of circles on the screen and moves them every frame. You should be able to set the number of circles to anything you like by changing the value of the numberOfBalls variable at the top. Hopefully this is of some use to you (or someone else.)
package {
// imports import flash.display.*; import mx.core.*; import mx.collections.*; import flash.events.*; [SWF(width = "640", height = "480", backgroundColor = "0x000000", frameRate = "40"] public class newTest extends MovieClip { public var ballArray:ArrayCollection = new ArrayCollection(); public var numberOfBalls:int = 2500; public var range1:int = int(numberOfBalls * 0.25); public var range3:int = int(numberOfBalls * 0.50); public var range2:int = int(range3 - 1); public var range5:int = int(numberOfBalls * 0.75); public var range4:int = int(range5 - 1); public function newTest():void { for (var i:Number = 0; i < numberOfBalls; i++){ createBall(); } addEventListener(Event.ENTER_FRAME, ballUpdate); } public function createBall():void { var ballSprite:Sprite = new Sprite(); ballSprite.graphics.beginFill(0x00FF00); ballSprite.graphics.drawCircle(0, 0, 2); ballSprite.x = 200; ballSprite.y = 200;
addChild(ballSprite); ballArray.addItem(ballSprite); } public function ballUpdate(e:Event):void { for each(var ballSprite:Sprite in ballArray) { var min:Number = 0; var max: Number = 25; var newNumber1:Number = Math.random() * (max - min) + min; var newNumber2:Number = Math.random() * (max - min) + min; var newX:int = int(newNumber1); var newY:int = int(newNumber2); var ballIndex:int = ballArray.getItemIndex(ballSprite); if(ballIndex >= range1 && ballIndex <= range2){ newX *= -1; } if(ballIndex >= range3 && ballIndex <= range4){ newY *= -1; } if(ballIndex >= range5){ newX *= -1; newY *= -1; }
I'd like to note, it may take adjusting the numberOfBalls variable to a fairly high number to get lag. It doesn't seem to lag on my machine with 1000 balls, but 4000 lags tons.