AUTOSCROLLING CMS
Hold down a button and watch it go.
madriel222- 07/22/2008 12:00 AM
- 2250 views
So you've created your custom menu. All of those pretty pictures, a brilliant layout, and amazing functionality. What's the problem? Your custom menu still moves slower than your drunk uncle Jim at a family reunion.
You've probably noticed that in many commercial games, the menus have an autoscroll feature. For those of you not hip to the lingo, autoscroll refers to the process that occurs when a player holds down a particular key. You press "Down," for example, and the cursor does not move down one measly spot, but rather keeps going until you release the button. That is what this tutorial will show you how to construct.
To begin, if you followed my custom menu system tutorial from earlier (much earlier, lol), you should have something like this as your menu system right now:
Ignore all of the numbers, as they will be different from what you have (you set up your variables and the like based on your own, unique setup). The nice part about this trick is that you don't need to mess with the meat of your code. We'll actually only work right below the beginning of the loop.
Immediately after the Loop command, put down a variable operation that sets "Move Cursor" equal to zero. We'll be using quite a few Key Input Processing commands, and this is necessary to make sure that our numbers stay straight. After this command, put a Wait command equal to .1 seconds, this ensures that all of this looping and scrolling is moving at a pace that your pictures and other code can handle (keeps the cursor in the right place). Now, put down a Key Input Processing command that ONLY checks for your arrow keys. After all, the escape key and the input key shouldn't be scrolling, lol. Furthermore, uncheck the box for "Wait Until Key Pressed." We do NOT want it to wait. This is what we have added thus far:
Not too bad so far, right? This next part might get slightly convoluted, so pay attention to the code box below if any of this isn't making sense.
Now insert a conditional branch that checks if the "Move Cursor" variable is greater than or equal to 1. What this does is check if a button is being pressed. If so (so inside of this conditional branch), immediately make a new conditional branch that checks if the new switch "PAUSE" is OFF. This switch will prevent the cursor from scrolling too fast. Within this new conditional branch, make a switch operation that turns "PAUSE" ON, make a variable operation that sets "Move Cursor" equal to 0, create a Wait command for .1 seconds, and finally put down a Key Input Processing command that checks for the four arrow keys (you may copy and paste the Key Input Processing command from before into this spot). Again, this Key Input Processing command should NOT wait until the key is pressed, this command is merely checking if the key is still being pressed.
Ok, now OUTSIDE of the Conditional Branch referencing switch "PAUSE", but INSIDE the Conditional Branch referencing variable "Move Cursor," put a Jump to Label command to a label that you have not yet used in this event (I'll be using 30 just for the heck of it). I know, I know, this sounds like a total trainwreck, but just take a look at the code, it's not terribly difficult!
Three quick steps and then you are finished! Outside of all those conditional branches, make a Key Input Processing command that DOES WAIT and checks for all the necessary keys. This is the one that you are used to seeing in custom menu codes, looking for the arrows as well as the enter and escape keys. Immediately following, put down a switch operation that turns "PAUSE" OFF. Lastly, slap in your Label! That's it, autoscrolling menu!
Until next time everyone, this is madriel222, signing off.
You've probably noticed that in many commercial games, the menus have an autoscroll feature. For those of you not hip to the lingo, autoscroll refers to the process that occurs when a player holds down a particular key. You press "Down," for example, and the cursor does not move down one measly spot, but rather keeps going until you release the button. That is what this tutorial will show you how to construct.
To begin, if you followed my custom menu system tutorial from earlier (much earlier, lol), you should have something like this as your menu system right now:
Variable Oper: [0001: CursorX] Set, 60
Variable Oper: [0002: CursorY] Set, 33
Variable Oper: [0003: CursorPosition] Set, 1
Show Picture: 40, Cursor, (V[0001], V[0002])
Loop
Key Input Proc: [0004: MoveCursor]
Branch if Var[0004: MoveCursor] is 1
Branch if Var[0003: CursorPosition] is 8
Variable Oper: [0002: CursorY] -, 147
Play Sound: choice1
Move Picture: 31, (V[0001], V[0002]), 0.1 Sec (Wait)
Variable Oper: [0003: Cursor Position] Set, 1
Else Handler
Variable Oper: [0002: CursorY] +, 21
Variable Oper: [0003: CursorPosition] +, 1
Play Sound: choice1
Move Picture: 31, (V[0001], V[0002]), 0.1 Sec (Wait)
End
End
Branch if Var[0004: MoveCursor] is 4
Branch if Var[0003: CursorPosition] is 1
Variable Oper: [0002: CursorY] +, 147
Play Sound: choice1
Move Picture: 31, (V[0001], V[0002]), 0.1 Sec (Wait)
Variable Oper: [0003: Cursor Position] Set, 8
Else Handler
Variable Oper: [0002: CursorY] -, 21
Variable Oper: [0003: CursorPosition] -, 1
Play Sound: choice1
Move Picture: 31, (V[0001], V[0002]), 0.1 Sec (Wait)
Branch if Var[0004: Move Cursor] is 2
Comment: LEFT HANDLER, WHATEVER THAT IS FOR YOU
Branch if Var[0004: Move Cursor] is 3
Comment: RIGHT HANDLER, WHATEVER THAT IS FOR YOU
Branch if Var[0004: Move Cursor] is 5
Comment: ENTER KEY HANDLER
Branch if Var[0004: Move Cursor] is 6
Comment: EXIT KEY HANDLER
End Loop
Ignore all of the numbers, as they will be different from what you have (you set up your variables and the like based on your own, unique setup). The nice part about this trick is that you don't need to mess with the meat of your code. We'll actually only work right below the beginning of the loop.
Immediately after the Loop command, put down a variable operation that sets "Move Cursor" equal to zero. We'll be using quite a few Key Input Processing commands, and this is necessary to make sure that our numbers stay straight. After this command, put a Wait command equal to .1 seconds, this ensures that all of this looping and scrolling is moving at a pace that your pictures and other code can handle (keeps the cursor in the right place). Now, put down a Key Input Processing command that ONLY checks for your arrow keys. After all, the escape key and the input key shouldn't be scrolling, lol. Furthermore, uncheck the box for "Wait Until Key Pressed." We do NOT want it to wait. This is what we have added thus far:
Variable Oper: [0001: CursorX] Set, 60
Variable Oper: [0002: CursorY] Set, 33
Variable Oper: [0003: CursorPosition] Set, 1
Show Picture: 40, Cursor, (V[0001], V[0002])
Loop
Variable Oper: [0004: Move Cursor] Set, 0
Wait 0.1 Seconds
Key Input Proc: [0004: Move Cursor] **NO WAIT**
*****REST OF MENU CODE*****
Not too bad so far, right? This next part might get slightly convoluted, so pay attention to the code box below if any of this isn't making sense.
Now insert a conditional branch that checks if the "Move Cursor" variable is greater than or equal to 1. What this does is check if a button is being pressed. If so (so inside of this conditional branch), immediately make a new conditional branch that checks if the new switch "PAUSE" is OFF. This switch will prevent the cursor from scrolling too fast. Within this new conditional branch, make a switch operation that turns "PAUSE" ON, make a variable operation that sets "Move Cursor" equal to 0, create a Wait command for .1 seconds, and finally put down a Key Input Processing command that checks for the four arrow keys (you may copy and paste the Key Input Processing command from before into this spot). Again, this Key Input Processing command should NOT wait until the key is pressed, this command is merely checking if the key is still being pressed.
Ok, now OUTSIDE of the Conditional Branch referencing switch "PAUSE", but INSIDE the Conditional Branch referencing variable "Move Cursor," put a Jump to Label command to a label that you have not yet used in this event (I'll be using 30 just for the heck of it). I know, I know, this sounds like a total trainwreck, but just take a look at the code, it's not terribly difficult!
Variable Oper: [0001: CursorX] Set, 60
Variable Oper: [0002: CursorY] Set, 33
Variable Oper: [0003: CursorPosition] Set, 1
Show Picture: 40, Cursor, (V[0001], V[0002])
Loop
Variable Oper: [0004: Move Cursor] Set, 0
Wait 0.1 Seconds
Key Input Proc: [0004: Move Cursor] **NO WAIT**
Branch if Var[0004: Move Cursor] is 1 or MORE
Branch if Switch[0005: PAUSE] is OFF
Switch Operation:[0005: PAUSE] ON
Variable Oper: [0004: Move Cursor] Set, 0
Wait 0.1 Seconds
Key Input Proc: [0004: Move Cursor] **NO WAIT**
End
Jump to Label: 30
End
*****REST OF MENU CODE*****
Three quick steps and then you are finished! Outside of all those conditional branches, make a Key Input Processing command that DOES WAIT and checks for all the necessary keys. This is the one that you are used to seeing in custom menu codes, looking for the arrows as well as the enter and escape keys. Immediately following, put down a switch operation that turns "PAUSE" OFF. Lastly, slap in your Label! That's it, autoscrolling menu!
Variable Oper: [0001: CursorX] Set, 60
Variable Oper: [0002: CursorY] Set, 33
Variable Oper: [0003: CursorPosition] Set, 1
Show Picture: 40, Cursor, (V[0001], V[0002])
Loop
Variable Oper: [0004: Move Cursor] Set, 0
Wait 0.1 Seconds
Key Input Proc: [0004: Move Cursor] **NO WAIT**
Branch if Var[0004: Move Cursor] is 1 or MORE
Branch if Switch[0005: PAUSE] is OFF
Switch Operation:[0005: PAUSE] ON
Variable Oper: [0004: Move Cursor] Set, 0
Wait 0.1 Seconds
Key Input Proc: [0004: Move Cursor] **NO WAIT**
End
Jump to Label: 30
End
Key Input Proc: [0004: Move Cursor] **YES WAIT**
Switch Operation: [0005: PAUSE] OFF
Label 30
*****REST OF MENU CODE*****
Until next time everyone, this is madriel222, signing off.
Pages:
1














