R
RylanStylin
Guest
I'm trying to make a menu system for my new game. Currently I am making a world select page. This is what it looks like.
Nice and simple, right? here is the code for it
First: code for main menu
Second: array for main menu. set in a create event in same object as to code.
this is the code i'm using to run this screen. As you can see, if you press "D", 1 gets added to the variable global.Wselect, which from its default position (1) makes it go to 2, and 2 will start flashing because of the loop, right? wrong. when I press "D" on the keyboard, global.Wselect is set to 2 the first frame, then 3 the second frame, then 4 the third frame, and 4 starts flashing. So in practice it jumps 3 instead of 1. I have tried everything to fix this, even making a new project and revising my code, but it haunts me over to the new project as well. the code is in a switch statement in the "step" event. on a global, persistent object placed in the room.
PLEASE SEND HELP!!!!
TL;DR: When I press "D" on the keyboard it adds 3 instead of 1.
[ATTACH type="full"]36183[/ATTACH]
Nice and simple, right? here is the code for it
GML:
case rWorldSelect:
if(keyboard_check_pressed(ord("A"))){
World[global.Wselect].image_alpha = 1;
global.Wselect -= 1;
}
if(keyboard_check_pressed(ord("D"))){
World[global.Wselect].image_alpha = 1;
global.Wselect += 1;
}
if(global.Wselect < 0) global.Wselect = 8;
if(global.Wselect > 8) global.Wselect = 0;
loop++;
if(loop < 15) World[global.Wselect].image_alpha = 0;
if(loop > 14) World[global.Wselect].image_alpha = 1;
if(loop > 30) loop = 0;
break;
}
Code:
World = [L1,L2,L3,L4,L5,L6,L7,L8,LReturn];
Second: array for main menu. set in a create event in same object as to code.
this is the code i'm using to run this screen. As you can see, if you press "D", 1 gets added to the variable global.Wselect, which from its default position (1) makes it go to 2, and 2 will start flashing because of the loop, right? wrong. when I press "D" on the keyboard, global.Wselect is set to 2 the first frame, then 3 the second frame, then 4 the third frame, and 4 starts flashing. So in practice it jumps 3 instead of 1. I have tried everything to fix this, even making a new project and revising my code, but it haunts me over to the new project as well. the code is in a switch statement in the "step" event. on a global, persistent object placed in the room.
PLEASE SEND HELP!!!!
TL;DR: When I press "D" on the keyboard it adds 3 instead of 1.
Attachments
-
55.4 KB Views: 16
Last edited by a moderator: