Best practices for managing state

Any there any good examples or suggestions of managing state? I’ve been struggling with responding to sprite position and state in certain parts of my update method and then actually updating state in other places within the update method. I’m struggling to keep things organized and wondering if there’s a good approach to managing state within (Phaser) games that someone could reference. I feel like my update method is hard to keep track of, fragile, spaghetti-ish, etc.

Can you elaborate a little more on specific scenario’s? I can think of many different patterns for state management but it depends on the scenario’s. Some could even be as simple as not managing the state but pausing a scene and resuming when ready (not your case I’m sure)

I agree that shoving more and more state related code in the scene’s update method feels gross. I’ve managed to get away from that by using state machines for different entities in my scenes. That’s worked pretty well for me.

I’ve also used an ECS architecture before that had different Systems with their own update methods that helped isolate their logic as well.