/// <summary> /// Allows the screen the chance to position the menu entries. By default /// all menu entries are lined up in a vertical list, centered on the screen. /// </summary> protected virtual void UpdateMenuEntryLocations() { // Make the menu slide into place during transitions, using a // power curve to make things look more interesting (this makes // the movement slow down as it nears the end). float transitionOffset = (float)Math.Pow(TransitionPosition, 2); // start at Y = 175; each X value is generated per entry Vector2 position = new Vector2(0f, 175f); // update each menu entry's location in turn for (int i = 0; i < menuEntries.Count; i++) { MenuEntry menuEntry = menuEntries[i]; // each entry is to be centered horizontally position.X = ScreenManager.GraphicsDevice.Viewport.Width / 2 - menuEntry.GetWidth(this) / 2; if (ScreenState == ScreenState.TransitionOn) { position.X -= transitionOffset * 256; } else { position.X += transitionOffset * 512; } // set the entry's position menuEntry.Position = position; // move down for the next entry the size of this entry position.Y += menuEntry.GetHeight(this); } }