Input issues
by Paul Blythe · in Torque X 2D · 03/29/2010 (8:37 am) · 5 replies
I'm using Torque X 2D and the Platformer starter kit.
I have hacked in a splash screen and a main menu.
Originally I was using GuiButtons, but after coming up against the vertex format bug I gave up and created a scene for my main menu in the builder.
The scene has a scrolling backdrop, a few animated sprites, and one animated sprite with a controller.
In the controller I use the following code to do the input bindings...
PlayerManager.Instance.GetPlayer(0).ControlObject = SceneObject;
InputMap inputMap = PlayerManager.Instance.GetPlayer(0).InputMap;
// gamepad controls
int gamepadId = InputManager.Instance.FindDevice("gamepad0");
if (gamepadId >= 0)
{
inputMap.BindMove(gamepadId, (int)XGamePadDevice.GamePadObjects.LeftThumbY, MoveMapTypes.StickAnalogVertical, 0);
inputMap.BindMove(gamepadId, (int)XGamePadDevice.GamePadObjects.A, MoveMapTypes.Button, 0);
}
ProcessList.Instance.AddTickCallback(owner, this);
And all is well.
Until I actually play the game, or go to a sub menu.
Once I have done this, the menu will never work again.
When I look at the tick callback, move.Sticks[0] is ALWAYS {0,0}
Anybody got a clue why as I am close to throwing torque down the toilet.
I have hacked in a splash screen and a main menu.
Originally I was using GuiButtons, but after coming up against the vertex format bug I gave up and created a scene for my main menu in the builder.
The scene has a scrolling backdrop, a few animated sprites, and one animated sprite with a controller.
In the controller I use the following code to do the input bindings...
PlayerManager.Instance.GetPlayer(0).ControlObject = SceneObject;
InputMap inputMap = PlayerManager.Instance.GetPlayer(0).InputMap;
// gamepad controls
int gamepadId = InputManager.Instance.FindDevice("gamepad0");
if (gamepadId >= 0)
{
inputMap.BindMove(gamepadId, (int)XGamePadDevice.GamePadObjects.LeftThumbY, MoveMapTypes.StickAnalogVertical, 0);
inputMap.BindMove(gamepadId, (int)XGamePadDevice.GamePadObjects.A, MoveMapTypes.Button, 0);
}
ProcessList.Instance.AddTickCallback(owner, this);
And all is well.
Until I actually play the game, or go to a sub menu.
Once I have done this, the menu will never work again.
When I look at the tick callback, move.Sticks[0] is ALWAYS {0,0}
Anybody got a clue why as I am close to throwing torque down the toilet.
#3
Set up your player like this:
03/30/2010 (12:27 pm)
When changing scenes, it is best to re-create your InputMap.Set up your player like this:
PlayerManager.Instance.GetPlayer(PlayerNumber).ControlObject = SceneObject;
PlayerManager.Player _player = PlayerManager.Instance.GetPlayer(PlayerNumber);
// Get input map for player one and configure it.
InputMap inputMap = new InputMap();
_player.InputMap = inputMap;
int gamepadId = InputManager.Instance.FindDevice("gamepad" + PlayerNumber);
if (gamepadId >= 0)
{
inputMap.BindAction(gamepadId, (int)XGamePadDevice.GamePadObjects.LeftThumbUpButton, _OnUpButton);
...
}
#5
03/31/2010 (2:10 am)
I'm a freelance coder, The client bought the licenses and supplied me with the system on a "for this job" basis
Torque 3D Owner Henry Shilling
Smokin Skull