This means the user can choose a menu option even while it is still fading in - its a good idea not to make the user wait, as this leads to frustration.
Games are about enjoyment, so we want to keep the user happy.
Therefore, the code to check the pointer goes after the endif command in the menu block.
if getPointerPressed() > 0 // Pointer Pressed elseif getPointerReleased() > 0 // Pointer Released elseif getPointerState() // Pointer Held endifThis works in a similar fashion to the game pointer checks and so uses a similar structure.
There is an established process for menu operation that a well coded menu follows.
- When the user first presses a menu item, that item is highlighted. Nothing more
- If the user keeps the pointer pressed and moves off the item, the item is un-highlighted
- If the user releases on the same item, then and only then is the selection accepted.
Each of those actions is handled by a different loop in the above structure, but before anything can happen we need another place to store the value.
This will be in a new field in the touchType UDT.
menuPickedThis will hold the selected menu item between program loops.
As always, there is a return function.
function MenuPicked() endfunction touch.menuPickedand it is set up in the Initialise() function.
touch.menuPicked = 0Now we need to decide how the menu item will be highlighted. This should be in a way that won't interfere with any transition running.
The easiest way is to use colour - something we haven't used yet. So lets' start by defining the colours of our menu text.
Colour is made up of three components, Red, Green and Blue. So the best way to set the normal values is to define some constants for these.
#constant MENU_RED 255 #constant MENU_GREEN 165 #constant MENU_BLUE 0Each component is assigned a value between 0 and 255, with 0 being none and 255 being full. The values defined above will give orange.
To highlight a selected Menu item, we could change it to Yellow, which is different only in that the Green value is changed to 255.
Firstly we need to set the initial values in the part of the menu loop, by changing the line.
setTextColorAlpha( menuText[ i ] , 0 )Which previously only set the alpha value, to.
setTextColor( menuText[ i ] , MENU_RED , MENU_GREEN, MENU_BLUE , 0 )This sets the colour of each menu item when the menu is first called. It still also sets the alpha to zero.
Now when the menu text fades in it will be orange rather than white.
No comments:
Post a Comment