Jump to content
  • Advertisement

Optimization How to implement control of the state of ui buttons?

This topic is 540 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello everyone!

Im using mvc framework for wrapper. So i have UIController, UIView for this problem.

The object of type UIView is display object and works as container(like in ActionScript). So it holds some static buttons wich control sound,fullscreen and etc. and another dynamic controls wich control the state and current rules of the game.

When the game is in different states  the buttons can be active or inactive for pressing, can be with different texts over them, wich can cause different functionallity to be performed in the controller.

So i have around 10-13 states of the game in wich the ui buttons are in different state so:

  1. Control state of the buttons in the controller. It is not ok cuz the controller is more than 300 rows and its ugly for reading and understanding. It shouldnt be.
  2. To create custom object in the controller and to pass to it the ui buttons and with some function called changeState to set the appropriate appearance to the buttons.

How to structure and name that custom object to be enough descriptive. Or is there some well known pattern ? Or do u have better idea ?

Edited by amkamkamk
More descriptive

Share this post

Link to post
Share on other sites

Conceptually, I'd say the model contains button state, or provide values for them, if you can derive them from other data in the model. If their state cannit be derived fully, then yes, the controller should provide any missing data values such that the viewer can reflect that in the display.

If the controller is bad, then I'd suggest to clean it up first. It takes some time, but in my experience it pays for itself. Making further changes in the controller is easier, faster, and with less errors.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!