How to make a menu bar

Non-platform specific questions.

How to make a menu bar

Postby dzuncoi » Sat Aug 25, 2012 3:03 pm

Can anyone show me how to create menu bar include "start game', "exit game", "level select" ... or something like that. I have no idea how to make it
dzuncoi
 
Posts: 33
Joined: Tue Jun 05, 2012 11:15 am
Score: 0 Give a positive score

Re: How to make a menu bar

Postby Fojam » Sat Aug 25, 2012 4:09 pm

create actors for each button and on mouse button down events, have them run ExitGame() or loadGame() or whatever
CLICK TO GIVE ME POINTS

My Latest Projects:
Super Smash Bros: viewtopic.php?f=6&t=12307 PLEASE help by making sprites!
User avatar
Fojam
 
Posts: 513
Joined: Thu Mar 19, 2009 10:02 pm
Location: under your bed!!!
Score: 69 Give a positive score

Re: How to make a menu bar

Postby dzuncoi » Sat Aug 25, 2012 5:09 pm

What about start game or choosing level ? Like when we press enter or click mouse button, the screen will move to out character and we can start the game
dzuncoi
 
Posts: 33
Joined: Tue Jun 05, 2012 11:15 am
Score: 0 Give a positive score

Re: How to make a menu bar

Postby skydereign » Sat Aug 25, 2012 7:36 pm

That is just done as code in the mouse button down events. To start the game, you'd probably move the view to the first level and create the player (or if the game is in another ged, use LoadGame). If the button is supposed to take you to another menu to select a character, just move the view. It should be pretty straightforward as it is exactly how you would program it if it were in the actual game (in gE menus are just part of the game).
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: How to make a menu bar

Postby dzuncoi » Tue Aug 28, 2012 5:24 pm

well i have another problem, like i want the character hit the monster 3 times then it dies, i use a code like this
monster -> Create actor -> Script Editor:
Code: Select all
die = 0;


monster -> Draw actor -> Script Editor:
Code: Select all
if (die == 3)
{
DestroyActor("monster");
}


monster -> Collision -> anyside of "player"-> Script Editor:
Code: Select all
if(collide.attack == 1)
{
die+=1;
}


but it doesn't work, player just hit 2 times and monster die, where is my mistake?
dzuncoi
 
Posts: 33
Joined: Tue Jun 05, 2012 11:15 am
Score: 0 Give a positive score

Re: How to make a menu bar

Postby dzuncoi » Tue Aug 28, 2012 5:30 pm

i checked in some ways and realized that it counts 2 times in the first hit and 1 time in the next hit so the monster die with only 2 hits, what happend with my code ?
dzuncoi
 
Posts: 33
Joined: Tue Jun 05, 2012 11:15 am
Score: 0 Give a positive score

Re: How to make a menu bar

Postby skydereign » Tue Aug 28, 2012 6:14 pm

Chances are you have the collision event set to repeat. If so, every frame of the collision it will increase the die variable. Assuming the attack variable shows that the player is attacking, you can just set it to 0 so the player will have to attack again to deal the next hit.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: How to make a menu bar

Postby dzuncoi » Tue Aug 28, 2012 6:50 pm

Can you explain more clearly ?
For example, "space" key down -> player attack -> attack = 1 then "space" key up -> stop attack -> attack = 0. So i just press "space" then player attack and it will increase die by 2 immediately (i changed collision event not to repeat already), so where should i set attack to 0 ?
dzuncoi
 
Posts: 33
Joined: Tue Jun 05, 2012 11:15 am
Score: 0 Give a positive score

Re: How to make a menu bar

Postby skydereign » Tue Aug 28, 2012 7:16 pm

Explaining and telling you exactly how to do it are different. I try not to tell people exactly how to solve things, because they usually end up copying it and not learning from it. The point I was making though is that if the collision event between the monster and the player is set to repeat, then that if statement will trigger every frame that the actors are colliding, which is the only way (from the code you gave) that would cause that problem.

If you've already set it to disable, then perhaps there is a problem in game that you haven't posted the code for (like having more than one collision event), or your animation actually collides with the enemy twice in a single attack.

To do what I was suggesting though is pretty straightforward. If you wanted the if statement to only trigger once, even if the code repeats over and over, all you need to do is within the if statement (where it says do something) put some code that changes the value of var (for instance resetting it to 0).
Code: Select all
if(var==1)
{
    // do something
    // setting var equal to 0 here would make the if statement no longer trigger
}


If what you posted really is the only way the die variable is changed, then doing the same with the if(collide.attack==1) statement will make it so you can only change the die variable once per attack.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron