BondoBondo
Member
I have a menu that I want to move up and down with my gamepad left stick. I'm not sure how to code for it though. Here is how I am doing it successfully with either the keyboard or D-pad on the controller.
I'm guessing I need to do something with gp_axislv, but I can't seem to get it to work.
I'm guessing I need to do something with gp_axislv, but I can't seem to get it to work.
GML:
//get input
var _up = keyboard_check_pressed(vk_up) || (gamepad_button_check_pressed(0, gp_padu));
var _down = keyboard_check_pressed(vk_down) || (gamepad_button_check_pressed(0, gp_padd));
var _select = keyboard_check_pressed(vk_enter) || (gamepad_button_check_pressed(0, gp_face1));
//move selection
var _move = _down - _up;
if _move != 0 {
//move the index
index += _move;
//clamp values
var _size = array_length_1d(menu);
if index < 0 index = _size - 1; //at start, so loop to menu end
else if index >= _size index = 0; //at end, so loop to menu start
}
if _select {
switch(index) {
case 0:
//New Game
room_goto(Level1);
break;
case 1:
//Continue
LoadGame(global.gameSaveSlot);
break;
case 2:
//Exit
game_end();
break;
}
}