Game Development Reference
In-Depth Information
Next, we will talk about the return type. Someimes, when we use JavaScript, we don't
really care about what type to return or what type of parameters we will pass to the
funcion, because it is really convenient to type only var myParams = 0 or function
DoSomething(var) . This isn't a bad thing to do, but if we are working with a team of
people, it is very important to have code that is readable for others. So, it is beter to have
this habit. It also makes the code run faster, since it doesn't have to go and do type lookups.
On the other hand, if we use C#, we will be forced by the language itself to type the return
type of this funcion or the type of this parameter. So, it's a good thing to know because you
will be able to read C# code easily if you have to and it is readable for everyone, even the
person using C#.
Adding a sound and replay button
Finally, we are in the last step of this chapter. We will add sound effects and a simple replay
buton for us to be able play this again.
Prepare for Lift Off
Let's make sure that we have all the graphics that we need for the replay buton; go to the
Chapter1 folder in the Project window, and make sure we have restartButtonOut.
png and restartButtonOver.png in our subfolder Buttons . We also need some sound
effects to use for our character, go to our Sound subfolder. We will see button_click.
aiff , doorOpen.wav , getKey.aiff , and Jump.wav . Unity, by default, translates every
sound that we import in our project to 3D, but we don't really need it as we are creaing a 2D
game. So, we will click on each sound in the Sound folder in the Project view and go to their
Inspector window and uncheck 3D Sound and then click on the Apply buton:
 
Search WWH ::




Custom Search