Page 1 of 2

Menus

PostPosted: Sat Jan 22, 2011 4:57 pm
by Turon
How do make a simple game menu? :roll:

Re: Menus

PostPosted: Sat Jan 22, 2011 5:02 pm
by Game A Gogo
You use what you know!

like having a filled region over a text actor to make a button, when clicking on a button you can either load the game or change the view position to change screen, make sure to have a back button :)

Re: Menus

PostPosted: Sat Jan 22, 2011 5:04 pm
by Turon
I have tried many times......... I don't know the codes! :(

Re: Menus

PostPosted: Sat Jan 22, 2011 5:17 pm
by Hblade
To create a Menu:

Make a text actor with the list of selections, make the size 14. Now make a Canvas actor and put this code:
Code: Select all
erase(0, 189, 255, .60);

Place that code in Draw Actor, or Create Actor.
Make a variable called M_INDEX.

now this part is important, say you have like 6 options. Example:
    Items
    Status
    Equipment
    Journle
    Options
    Exit

M_INDEX's max number would be 5, because 0 counts ;) However many numbers you have, always remember that it's -1. So, for example if you have 24 selection items, then the max would be 23. You'll understand what I mean in the code.
Now make sevral events, KeyDown - Down
Code: Select all
if (M_INDEX<=5) {
    M_INDEX++;
    y+=16;
}
else if (M_INDEX==6) {
    M_INDEX=0;
    y-=(16*6);
}

Look carefully at the y-=(16*6);, because I can't remember if it's -1 for that too or not xD. Anyway, it should bounce the menu back to the top selection.

Now for KeyDown - Up
Code: Select all
if (M_INDEX>=0) {
    M_INDEX--;
    y-=16;
}
else if (M_INDEX==-1) {
    M_INDEX=5;
    y+=(16*6);
}


That should do the trick :D

Now all you gotta do for determining what option gets selected, is make a Key Down event for Enter, with something similar to this code.
KeyDown - Enter
Code: Select all
switch(M_INDEX) {
    case 0: //In our case, items
    //Your functions here
    break;
    case 1:
    //etc
    break;
}


Hope this helped :D

Re: Menus

PostPosted: Sat Jan 22, 2011 5:51 pm
by Turon
Thank You Hblade :D

Re: Menus

PostPosted: Sat Jan 22, 2011 11:34 pm
by Hblade
Lol np man :)

Re: Menus

PostPosted: Sun Jan 23, 2011 7:13 am
by Turon
the last code was a bit puzzling :?
Code: Select all
switch(M_INDEX) {
    case 0: //In our case, items
    //Your functions here
    break;
    case 1:
    //etc
    break;
}
can you explain it a bit more? :wink:

Re: Menus

PostPosted: Sun Jan 23, 2011 8:12 am
by schnellboot
ok so
case 0 is the first selection
you have to put there what it has to do when first thing is selected
for example if first is play and second is load then
Code: Select all
case 0:
view.x=300; //move the view to the game play area
view.y=400;
break; //you have to put this before every new case
case 1:
view.x=300;
view.y=400;
loadVars(blabla);


hope this helped

Re: Menus

PostPosted: Sun Jan 23, 2011 6:40 pm
by Hblade
Thanks, schnellboot :D

Re: Menus

PostPosted: Thu Jan 27, 2011 6:31 am
by Turon
schnellboot um do I put this in as well?:

move the view to the game play area

you have to put this before every new case

Re: Menus

PostPosted: Thu Jan 27, 2011 7:24 am
by schnellboot
you can but you don't have to

Re: Menus

PostPosted: Tue Feb 01, 2011 6:09 am
by Turon
Is it for loading or playing game?

Re: Menus

PostPosted: Tue Feb 01, 2011 6:17 am
by schnellboot
for everything you only have to set it up ..

Re: Menus

PostPosted: Tue Feb 01, 2011 6:20 am
by Turon
How must i edit it to play game? :D

Re: Menus

PostPosted: Tue Feb 01, 2011 8:35 am
by schnellboot
already explained that ..