I've always heard to not worry about optimization until it becomes a problem. Well now, it's become a problem. My game is very small and light on assets, so I'm surprised it's suddenly starting to lag. Problem is, I'm not sure why.
I've been doing a lot of work on my menu system, specifically the "Controls" section. The control section draws and animates boxes, sprites that represent the actions, and keys that are attached to each action, which can be modified. There's an "if" shader applied to each of the boxes that makes them appear white (off and on) when selected.
See video:
The menu system has switch states that make it so that most of the code in the Draw GUI event (1000 lines of it) are not even activated if the menu is unpaused. The "Control" section has its own state.
Problem is, since implementing the "Control" section of my menu, my game has started to lag a LOT. When I enter the first room, the frame rate drops to like 10 fps. What's strange is that when I open the menu and select "Controls" and exit out of the menu, the lag is gone. What could be causing this? How do I get rid of it?
I've been doing a lot of work on my menu system, specifically the "Controls" section. The control section draws and animates boxes, sprites that represent the actions, and keys that are attached to each action, which can be modified. There's an "if" shader applied to each of the boxes that makes them appear white (off and on) when selected.
See video:
The menu system has switch states that make it so that most of the code in the Draw GUI event (1000 lines of it) are not even activated if the menu is unpaused. The "Control" section has its own state.
Problem is, since implementing the "Control" section of my menu, my game has started to lag a LOT. When I enter the first room, the frame rate drops to like 10 fps. What's strange is that when I open the menu and select "Controls" and exit out of the menu, the lag is gone. What could be causing this? How do I get rid of it?