A certain event of an actor doesn't work?

Game Editor comments and discussion.

A certain event of an actor doesn't work?

Postby ayu04 » Mon Dec 19, 2011 7:03 pm

I made a game and my main menu is working at first but when I play a new game and I go back to the main menu, then the buttons doesn't work. What should I do?
ayu04
 
Posts: 20
Joined: Fri Nov 18, 2011 1:47 pm
Score: 0 Give a positive score

Re: A certain event of an actor doesn't work?

Postby Hblade » Mon Dec 19, 2011 9:53 pm

OH now I know what you mean :3

Alright, make sure that when you go back to the menu, all of the variables that control the menu are reset.
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: A certain event of an actor doesn't work?

Postby ayu04 » Tue Dec 20, 2011 1:59 am

what do you mean by resetting all of the variables that control the menu?please tell me how to reset variables? thank you for answering my question. :D
ayu04
 
Posts: 20
Joined: Fri Nov 18, 2011 1:47 pm
Score: 0 Give a positive score

Re: A certain event of an actor doesn't work?

Postby skydereign » Tue Dec 20, 2011 3:13 am

Usually when you handle a menu, you use variables to determine what to do. For instance you might have a variable that holds the overall state of the game (in menu, in game, paused, etc.). Assuming that's the case, you would have code like this.
play_button -> Mouse Button Down -> Script Editor
Code: Select all
switch(game_state)
{
    case 0: // in menu
    //CreateActor for player
    // move view
    game_state=2;
    break;
}

That way when game_state is 0 (you are in the menu), you press it and it will jump you into the game. But, if you go to click it again, it won't jump you into the game, because game_state is equal to 2. To "reset" the variable, just set it back to 0, since that is the default. So, if your menu uses variables in a similar fashion, you'll have to reset them when you go back to the menu after playing the game.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: A certain event of an actor doesn't work?

Postby ayu04 » Sat Dec 31, 2011 5:06 am

thank you :) by any chance can you teach me how to put background music and sound effects in the game? and what is the size and format required for the sound to play? Is it also possible to have an option if you want to switch on and off the sounds in the game? :)) thank you so much to all of you.
ayu04
 
Posts: 20
Joined: Fri Nov 18, 2011 1:47 pm
Score: 0 Give a positive score

Re: A certain event of an actor doesn't work?

Postby HitoV » Mon Jan 02, 2012 11:17 pm

Putting sfx and music is very easy with ge :D
As far as what format to use I personally think it depends on your target device. If you are going to make the game for pc you can really do anything, I would use 44.1khz wav files for sound effects and ogg's for music. If your target device is the iphone you might want to push it down to 22.05khz. I find that using 44.1khz on my itouch device causes random crashes.

You can make music play by adding...
level actor -> add event "create actor" -> "play music"

I am pretty sure you already have a script editor for your level so you may just want to add it in the script editor. Go to variables/functions tab in the script editor and select "play music2" It will bring up the same menu as the previous and then it will automatically write the script to do it for you.

Adding sound effects is very similar but you would probably want them to happen in different places. For instance when a bullet or something hits the wall or an enemy. You would put: bullet actor -> collision -> (collision with wall or enemy) -> play sound.

The thing to note is that sounds play on top of each other. So you can play a whole bunch simultaneously. Music however when called stops the current file playing and starts the next one.

You can control the volume of everything a few different ways. For me the easiest way to do this was to make a global variable sfx_volume and insert that into what should be the assigned volume for every sound effect. You would have to do these inside script editor to be able to edit the volume values correctly. Example:
Code: Select all
PlaySound2("C:\click.wav", 0.8, 1, 0.3);

In the above code 0.8 is the volume, 1 is the amount of times it will be played (loop), and 0.3 is the pan. You would just replace the volume with sfx_volume.
Code: Select all
PlaySound2("C:\click.wav", sfx_volume, 1, 0.3);


The music channel has this built in already so you would just need to call:
Code: Select all
sfx_volume = 0;
musicvol = 0;  //this is game editors built in volume control for the music

In order to mute it. If you would like to change them back just set them to 1.

I am sure others might write a simple for loop statement using "setVolume" but to me the above way gives you a little more control. If you do not have a means of "normalizing" the volume and you have one that is too loud you can easily knock it back by saying sfx_volume/1.2 or something to make it a little lower in volume.

Hope this works for you! Let me know if you need anything explained a little further :D
HitoV
 
Posts: 48
Joined: Sat Aug 27, 2011 8:22 am
Score: 3 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest