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

Talk about making games.

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

Postby ericdg » Fri Feb 17, 2006 11:38 am

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.
ericdg
 
Posts: 53
Joined: Tue Nov 29, 2005 1:18 pm
Score: 1 Give a positive score

Postby twobob » Fri Feb 17, 2006 2:47 pm

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
twobob
 
Posts: 33
Joined: Sat Sep 10, 2005 10:29 am
Location: England
Score: 2 Give a positive score

Postby ericdg » Wed Feb 22, 2006 2:48 pm

Thanks for the suggestion. I'll try that.

Does anyone else know of any other way?
ericdg
 
Posts: 53
Joined: Tue Nov 29, 2005 1:18 pm
Score: 1 Give a positive score

Postby Novice » Thu Feb 23, 2006 1:00 am

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...
Why do i always get stuck?
User avatar
Novice
 
Posts: 399
Joined: Mon Aug 29, 2005 10:54 am
Location: Relative
Score: 5 Give a positive score

Postby DilloDude » Thu Mar 02, 2006 1:58 am

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]
}
...
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score


Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest

cron