-1

I'm working on an overlay/HUD for a Java game, where the user should be able to enable or disable certain components and choose configuration options. One such example is a health bar, which the user can choose to either enable or disable and choose its size and color.

What would be a good design to handle this kind of scenario in Java? I'm particularly wondering how I should handle changes in configuration options, so that all HUD components could follow the same logic.

1 Answer 1

1

The usual way to propagate change is through the Observer pattern.

The HUD components register themselves as observers of the object holding the HUD configuration options.

The object holding the HUD configuration options notifies the HUD components of any change to its parameters.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.