Jump to content
  • Advertisement
Sign in to follow this  
RyanSchurton

2d Space shooter Main Menu Problem

This topic is 2475 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

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 m[/font][color=#111111][font=Helvetica, Arial, sans-serif]

enu I have came across a problem with my code.[/font]








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

using UnityEngine;[/font]
[color=#111111][font=Helvetica, Arial, sans-serif]

using System.Collections;[/font]
[color=#111111][font=Helvetica, Arial, sans-serif]

public class MainMenu : MonoBehaviour[/font]
[color=#111111][font=Helvetica, Arial, sans-serif]

{ [/font]
[color=#111111][font=Helvetica, Arial, sans-serif]

#region Fields[/font]
[color=#111111][font=Helvetica, Arial, sans-serif]

private string instructionText = "Instruction:\nPress Left and Right Awrrows to move.\nPress Spacebar to fire." [/font]
[color=#111111][font=Helvetica, Arial, sans-serif]

private int buttonWidth = 200;[/font]
[color=#111111][font=Helvetica, Arial, sans-serif]

private int buttonHeight = 50;[/font]
[color=#111111][font=Helvetica, Arial, sans-serif]

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

#region Properties[/font]
[color=#111111][font=Helvetica, Arial, sans-serif]

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

#region Functions[/font]
[color=#111111][font=Helvetica, Arial, sans-serif]

void OnGui()[/font]
[color=#111111][font=Helvetica, Arial, sans-serif]

{[/font]
[color=#111111][font=Helvetica, Arial, sans-serif]

GUI.Label(new Rect(10, 10, 250, 200), instructionText);[/font]
[color=#111111][font=Helvetica, Arial, sans-serif]

if (GUI.Button(new Rect((Screen.width / 2) - (buttonWidth / 2), [/font]
[color=#111111][font=Helvetica, Arial, sans-serif]

Screen.height / 2 - buttonHeight / 2, buttonWidth, buttonHeight), "Start Game")); [/font]
[color=#111111][font=Helvetica, Arial, sans-serif]

{[/font]
[color=#111111][font=Helvetica, Arial, sans-serif]

Application.LoadLevel(1); [/font]
[color=#111111][font=Helvetica, Arial, sans-serif]

}[/font]

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

} [/font]

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

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

}[/font]

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

[/font]

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

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. [/font]
[color=#111111][font=Helvetica, Arial, sans-serif]

private int buttonWidth = 200;[/font]
[color=#111111][font=Helvetica, Arial, sans-serif]

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. [/font][color=#111111][font=Helvetica, Arial, sans-serif]

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

cool.png[/font]

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


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


line.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!