Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


2d Space shooter Main Menu Problem


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 RyanSchurton   Members   -  Reputation: 100

Like
0Likes
Like

Posted 02 March 2012 - 12:15 AM

so I've been doing this little project and following a tutorial on 3d buzz to make a top down shooter. Well all was going smooth I have finished most of the game until I had to make a main menu I have came across a problem with my code.








using UnityEngine;[/size][/font][/color]
[color=#111111][font=Helvetica, Arial, sans-serif][size=3]using System.Collections;[/size][/font][/color]
[color=#111111][font=Helvetica, Arial, sans-serif][size=3]public class MainMenu : MonoBehaviour[/size][/font][/color]
[color=#111111][font=Helvetica, Arial, sans-serif][size=3]{ [/size][/font][/color]
[color=#111111][font=Helvetica, Arial, sans-serif][size=3]#region Fields[/size][/font][/color]
[color=#111111][font=Helvetica, Arial, sans-serif][size=3]private string instructionText = "Instruction:\nPress Left and Right Awrrows to move.\nPress Spacebar to fire." [/size][/font][/color]
[color=#111111][font=Helvetica, Arial, sans-serif][size=3]private int buttonWidth = 200;[/size][/font][/color]
[color=#111111][font=Helvetica, Arial, sans-serif][size=3]private int buttonHeight = 50;[/size][/font][/color]
[color=#111111][font=Helvetica, Arial, sans-serif][size=3]#endregion[/size][/font][/color]
[color=#111111][font=Helvetica, Arial, sans-serif][size=3]#region Properties[/size][/font][/color]
[color=#111111][font=Helvetica, Arial, sans-serif][size=3]#endregion[/size][/font][/color]
[color=#111111][font=Helvetica, Arial, sans-serif][size=3]#region Functions[/size][/font][/color]
[color=#111111][font=Helvetica, Arial, sans-serif][size=3]void OnGui()[/size][/font][/color]
[color=#111111][font=Helvetica, Arial, sans-serif][size=3]{[/size][/font][/color]
[color=#111111][font=Helvetica, Arial, sans-serif][size=3]  GUI.Label(new Rect(10, 10, 250, 200), instructionText);[/size][/font][/color]
[color=#111111][font=Helvetica, Arial, sans-serif][size=3]  if (GUI.Button(new Rect((Screen.width / 2) - (buttonWidth / 2),  [/size][/font][/color]
[color=#111111][font=Helvetica, Arial, sans-serif][size=3]					   Screen.height / 2 - buttonHeight / 2, buttonWidth, buttonHeight), "Start Game")); [/size][/font][/color]
[color=#111111][font=Helvetica, Arial, sans-serif][size=3]  {[/size][/font][/color]
[color=#111111][font=Helvetica, Arial, sans-serif][size=3]    Application.LoadLevel(1);				  [/size][/font][/color]
[color=#111111][font=Helvetica, Arial, sans-serif][size=3]  }[/size][/font][/color]

[color=#111111][font=Helvetica, Arial, sans-serif][size=3]} [/size][/font][/color]

[color=#111111][font=Helvetica, Arial, sans-serif][size=3]#endregion[/size][/font][/color]
[color=#111111][font=Helvetica, Arial, sans-serif][size=3]}[/size][/font][/color]

[color=#111111][font=Helvetica, Arial, sans-serif][size=3]


I am getting an error in unity that says Assets/Scripts/MainMenu.cs(9,15): error CS1519: Unexpected symbol `private' in class, struct, or interface member declaration.
private int buttonWidth = 200;

there is a red line under it but I cant seem to find out what is wrong. Hopefully someone who is awesome can. If you have any question or if I am leaving something out please let me know. Posted Image

Sponsor:

#2 RyanSchurton   Members   -  Reputation: 100

Like
0Likes
Like

Posted 02 March 2012 - 12:17 AM

using UnityEngine;
using System.Collections;
public class MainMenu : MonoBehaviour
{
#region Fields
private string instructionText = "Instruction:\nPress Left and Right Awrrows to move.\nPress Spacebar to fire."
private int buttonWidth = 200;
private int buttonHeight = 50;
#endregion
#region Properties
#endregion
#region Functions
void OnGui()
{
  GUI.Label(new Rect(10, 10, 250, 200), instructionText);
  if (GUI.Button(new Rect((Screen.width / 2) - (buttonWidth / 2),
					   Screen.height / 2 - buttonHeight / 2, buttonWidth, buttonHeight), "Start Game"));
  {
	Application.LoadLevel(1);				
  }

}

#endregion
}


sorry about what happen above and the double post but this is the code for my main menu.

#3 SimonForsman   Crossbones+   -  Reputation: 6693

Like
0Likes
Like

Posted 02 March 2012 - 12:59 AM

add a semicolon at the end of the:
private string instructionText = "Instruction:\nPress Left and Right Awrrows to move.\nPress Spacebar to fire."


line.
I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS