Jump to content

  • Log In with Google      Sign In   
  • Create Account

#Actualrip-off

Posted 08 April 2013 - 01:49 AM

No, inheritance would not be used for this. You can either make them public named constants in whichever class makes the most sense to you (e.g. Game1). If none of your existing classes suit, you can make a separate "Constants" class containing just these.

In addition, try to compute things from as few constants as possible. For instance, your three buttons are spaced 35 pixels apart, at 500, 535 and 570. Let use say you want to move the button list a bit. You must change each constant. If you wanted to increase this spacing to 40 pixels, you now have to modify the last two values.

However, you could also express this in terms of just two constants, TopButtonLocation and ButtonSpacing. So the first button is located at TopButtonLocation, the second at TopButtonLocation + ButtonSpacing and the last at TopButtonLocation + (2 * ButtonSpacing) (you could also express the second as playButton.position.X + ButtonSpacing.

Now, to shift the entire menu, just change the TopButtonLocation. To spread out the menu items, just change the ButtonSpacing.


#1rip-off

Posted 08 April 2013 - 01:48 AM

No, inheritance would not be used for this. You can either make them public named constants in whichever class makes the most sense to you (e.g. Game1). If none of your existing classes suit, you can make a separate "Constants" class containing just these.<br /><br />In addition, try to compute things from as few constants as possible. For instance, your three buttons are spaced 35 pixels apart, at 500, 535 and 570. Let use say you want to move the button list a bit. You must change each constant. If you wanted to increase this spacing to 40 pixels, you now have to modify the last two values.<br /><br />However, you could also express this in terms of just two constants, TopButtonLocation and ButtonSpacing. So the first button is located at TopButtonLocation, the second at TopButtonLocation + ButtonSpacing and the last at TopButtonLocation + (2 * ButtonSpacing) (you could also express the second as playButton.position.X + ButtonSpacing.<br /><br />Now, to shift the entire menu, just change the TopButtonLocation. To spread out the menu items, just change the ButtonSpacing.

PARTNERS