Page 1 of 1

How can you make a menu you navigate with up/down and enter.

PostPosted: Fri Feb 17, 2006 11:38 am
by ericdg
Making a menu on pocket pc is easy, but what are some ways you have made a menu for a game using the up/down keys to navigate and a action or enter key to select.

I figure I can make a box around the menu option and use script editor to move the box a certain amount of pixels up or down, but how do I get it to select that particular option when I click the enter button.

PostPosted: Fri Feb 17, 2006 2:47 pm
by twobob
A bit long winded but this is one way
Create a variable to control your box position. - (int buttoncontrol)
Have one actor to control all key down events. (menucontroller) –also could use say background actor.
On Create (menucontroller) - script editor – initialize your variables
example :
buttoncontrol = 1;
box.x = 52; //where your first button is
box.y =100;

Add key down event for menucontroller, for say the ‘down’ key, add something like the following script
buttoncontrol = buttoncontrol + 1;
if(buttoncontrol == 3){buttoncontrol = 1;}
switch(buttoncontrol)
{
case 1:
box.x = 52; //if buttoncontrol == 1 then place box round button 1
box.y = 100;
return;

case 2:
box.x = 52; //if buttoncontrol == 2 then place box round button 2
box.y = 50;
return;
}
Add another key down event for menucontroller for the up key (to go up the menu)similar to above but altering:-
buttoncontrol = buttoncontrol - 1;
if(buttoncontrol == 0){buttoncontrol = 2;}

Add another key down event for menucontroller, say key ‘m’ for menu so that the user can choose the selected button that is marked with the box, and add similar to below
switch(buttoncontrol)
{
case 1:
//PUT YOUR CODE HERE FOR BUTTON 1 ACTION
break;

case 2:
//PUT YOUR CODE HERE FOR BUTTON 2 ACTION
}
Alter the case statements to suit your button actions – probably similar to your mouse down actions for the buttons

PostPosted: Wed Feb 22, 2006 2:48 pm
by ericdg
Thanks for the suggestion. I'll try that.

Does anyone else know of any other way?

PostPosted: Thu Feb 23, 2006 1:00 am
by Novice
Just one varibale that goes +1 on down and -1 on up.
So on button 1 actor
Code: Select all
if (variable==1) ChangeAnimation...

on button 2 actor
Code: Select all
if (variable==2) ChangeAnimation...

And so on
On enter use a switch or an if statement
Code: Select all
If (variable==1) Action...

PostPosted: Thu Mar 02, 2006 1:58 am
by DilloDude
You could use an animation with all states. Add on keydown down:
Code: Select all
int var=animpos
var+=1;
if(var>[total number of frames-1])
{
    var-=[total number of frames]
}
animpos=var
This will make it wrap; if you move off down, you will come to the top.
Add a similar thing for keydown up, but var-=1; if var<0; var+=[total number of frames]. Then, on keydown enter
Code: Select all
if(animpos==0)
{
    [menuaction 1]
}
else if(animpos==1)
{
    [menuaction 2]
}
...