Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and the Yahoo Answers website is now in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

Why does user input suddenly slow my flash game down?

I'm testing a game I'm creating. Out of nowhere, when I add input from the keyboard, mouse, etc. the game's frame rate slows down from 40fps to 5fps. When I don't input anything, the game stays at 40 fps. Why?

I didn't make any radical changes to the game, but I did recently download Itunes and pinnacle studio 10. Does that have anything to do with it?

1 Answer

Relevance
  • 1 decade ago
    Favorite Answer

    A lot depends on how you added in your keyboard & mouse input. Are you scanning these items on every cycle, or are you handling events from them? Where are the events being handled, and what takes place during the event handlers? For example, are you executing a giant case structure with every mouse click? Are you doing collision detection on every click? Calculating the square-root of pi? etc. You need to pay attention to what is being done by the program when a mouse or keyboard event occurs and how you're handling them. You can speed things up by focusing on these areas of code. For example, if you're doing a massive amount of trig calculations on every mouse move, then you may want to consider creating a simple look-up table of pre-calculated results rather than having the PC perform the calculations on every cycle.

    In general, if your Flash application is slowing down to 5fps, I'd say you have major problems with your code. Try to locate the sections of code that are hogging the CPU and optimize those sections.

    Without seeing your code, however, it's difficult for me to offer specific advice.

Still have questions? Get your answers by asking now.