Using a cursor to choose options from a main menu
by Arden · in Torque X 2D · 10/29/2010 (7:23 pm) · 3 replies
Hiya guys,
I'm trying to set up a main menu where a user can use the arrow key of the keyboard or the joystick to select options from the screen before starting the game. I would also like to display a cursor moving on screen for navigation. My question is: do I need to set up a scene for that and use static sprites, or is there another way I can manipulate different loaded materials on screen to achieve the same effect?
Here is the code from the main menu:
I'm trying to set up a main menu where a user can use the arrow key of the keyboard or the joystick to select options from the screen before starting the game. I would also like to display a cursor moving on screen for navigation. My question is: do I need to set up a scene for that and use static sprites, or is there another way I can manipulate different loaded materials on screen to achieve the same effect?
Here is the code from the main menu:
namespace StarterGame2D
{
class GuiMainMenu : GUIBitmap, IGUIScreen
{
// Constructor
public GuiMainMenu()
{
// create the Style for the main menu backdrop
GUIBitmapStyle bitmapStyle = new GUIBitmapStyle();
bitmapStyle.SizeToBitmap = false;
bitmapStyle.PreserveAspectRatio = true;
Name = "GuiMainMenu";
Style = bitmapStyle;
//Bitmap = @"data\images\MainMenu2.png";
Bitmap = @"data\images\Gui\MenuScreenDragon.png";
Size = new Vector2(1280, 720);
OnGUIWake = OnMainScreenWake;
// bind the first gamepad’s A and B buttons to start and exit the
// game accordingly
int gamepadId = InputManager.Instance.FindDevice("gamepad0");
InputMap.BindCommand(gamepadId, (int)XGamePadDevice.GamePadObjects.A, null, Game.Instance.StartGame);
InputMap.BindCommand(gamepadId, (int)XGamePadDevice.GamePadObjects.B, null, Game.Instance.Exit);
InputMap.BindCommand(gamepadId, (int)XGamePadDevice.GamePadObjects.Back, null, Game.Instance.Exit);
// bind the keyboards enter and escape keys to start and exit
// the game accordingly
int keyboardId = InputManager.Instance.
FindDevice("keyboard");
InputMap.BindCommand(keyboardId, (int)Microsoft.Xna.Framework.Input.Keys.A, null, Game.Instance.StartGame);
InputMap.BindCommand(keyboardId, (int)Microsoft.Xna.Framework.Input.Keys.Enter, null, Game.Instance.StartGame);
InputMap.BindCommand(keyboardId, (int)Microsoft.Xna.Framework.Input.Keys.Escape, null, Game.Instance.Exit);
InputMap.BindCommand(keyboardId, (int)Microsoft.Xna.Framework.Input.Keys.B, null, Game.Instance.Exit);
}
public void OnMainScreenWake(GUIControl mainGUI)
{
// perform your custom screen-activation tasks
}
}
}
#2
It lets you use pictures instead of just plain colours for your buttons.
Resource is here
10/31/2010 (6:24 pm)
You can also use an awesome resource called the GUI bitmap button.It lets you use pictures instead of just plain colours for your buttons.
Resource is here
#3
10/31/2010 (7:17 pm)
Great. That will come in handy! Thanks again.
Torque Owner Arden
static.garagegames.com/static/pg/blogs/michael-perry/An%20Introduction%20to%20th...
Now I'll just create the buttons I need.Really useful!