Y
Yvalson
Guest
So I'm currently setting up a system that should let players use a controller in my game.
however some text isn't showing up
I'm using this code inside a mouse left pressed event:
it should check in which state the gamepad detection button currently is.
(searching is set to 0 in the create event and global.gamepad is set to -1)
so when a player presses the button and nothing has happened yet it should start searching because searching will be set to 1.
this will start the searching code in the step event:
so when a player presses the home/start button of their controller the code should detect in which slot it is and then assign the slot number to global.gamepad.
following in which state the code is in this text should show up (Draw GUI event):
No gamepad connected and looking for gamepad... both show up. however the Gamepad connected text doesn't however using the show_message I can see that searching is set to 0 again and that global.gamepad != -1 however I'm not able to see the text or disconnect the controller by clicking on the detection button again. instead it will keep being in the connected state.
can someone tell me what's wrong?
however some text isn't showing up
I'm using this code inside a mouse left pressed event:
Code:
if(!searching && global.gamepad = -1){
searching = 1
}
else if(!searching && !global.gamepad = -1){
global.gamepad = -1
}
else if(searching && global.gamepad = -1){
searching = 0
}
(searching is set to 0 in the create event and global.gamepad is set to -1)
so when a player presses the button and nothing has happened yet it should start searching because searching will be set to 1.
this will start the searching code in the step event:
Code:
if(searching){
var gp_num = gamepad_get_device_count();
for (var i = 0; i < gp_num; i++;){
if gamepad_button_check(i, gp_start){
global.gamepad = i
searching = 0
show_message(string(searching) + string(global.gamepad))
break;
}
}
}
if(global.gamepad = -1){
sprite_index = Spr_Unselected
}
else if(global.gamepad != -1){
sprite_index = Spr_Selected
}
following in which state the code is in this text should show up (Draw GUI event):
Code:
draw_set_font(f_Store)
if(!searching && global.gamepad = -1){
draw_text(32, 520, "No gamepad connected")
draw_text(32, 580, "Disable this option before disconnecting.")
}
else if(searching && global.gamepad = -1){
draw_text(32, 520, "Looking for gamepad...")
draw_text(32, 580, "Press the Start/Option button.")
draw_text(32, 640, "Press the search button to stop.")
}
else if(!searching && !global.gamepad = -1){
draw_text(32, 520, "Gamepad connected!")
draw_text(32, 580, "Disable this option before disconnecting.")
}
can someone tell me what's wrong?