Copy link to clipboard
Copied
So I made a function that allows the player to hit the "p" key which will change the framerate of the game:
if (keys[80])
{
if(game_paused =="false"){
stage.frameRate = 0;
game_paused = "true";
}
if(game_paused =="true"){
stage.frameRate = 30;
game_paused = "false";
}
}
The problem is, when the key is pressed, the game seems to go at double the framerate, like 60 or maybe even higher than that. I have no clue why, I don't see how making the framerate EQUAL 30 would make it go HIGHER than that... any ideas? Thanks.
If it is all code-based, then chances are you need to deal with disabling anything that processes when you click the pause button. It can get fairly complex depending on how much you have going on at any given time. You might be able to simplify some of it if you build in conditional code where needed that essentially checks if a paused variable is set or not....
if(!game_paused) { code that processes when the game is running }
Copy link to clipboard
Copied
Without knowing more about your design I would say instead of changing the frameRate to 0, use stop();
Copy link to clipboard
Copied
The stage of the game takes place on one frame, there's many variables as well. Stop(); wouldn't do anything other than stop the already stopped frame.
Copy link to clipboard
Copied
Well, that's a start. Can you explain more about how your game code works? It might lead to getting some help with a solution.
Meanwhile, the valid range for the frame rate is from 0.01 to 1000 frames per second - meaning you cannot stop it, but specifying a 0 for it could lead to issues like you see. You should check out the help documentation to learn more about how the frameRate property works.
Copy link to clipboard
Copied
It's a two-player side-scroller fighting game. It's kind of difficult to just say how the game code works because there's so much to it, but basically, pressing certain keys on the keyboard will allow the characters to move around, attack, etc. The battle portion of the game takes place on a single frame. I'll try using 0.01.
Copy link to clipboard
Copied
If it is all code-based, then chances are you need to deal with disabling anything that processes when you click the pause button. It can get fairly complex depending on how much you have going on at any given time. You might be able to simplify some of it if you build in conditional code where needed that essentially checks if a paused variable is set or not....
if(!game_paused) { code that processes when the game is running }
Find more inspiration, events, and resources on the new Adobe Community
Explore Now