XNA Creators Club Online
Page 1 of 1 (9 items)
Sort Posts: Previous Next

Global Bool?

Last post 5/16/2008 1:28 AM by Daaark. 8 replies.
  • 5/13/2008 10:00 PM

    Global Bool?

    In one of my cs files, pressing a button makes ship1=true, so how do I make another cs file recognize that change? Please reply as soon as possible! THANKS!
  • 5/13/2008 10:23 PM In reply to

    Re: Global Bool?

    One option you have is to use the keyword "public" to make it accessible to other classes. It sounds like you are just starting out with C#. Before you get too far with the XNA framework and game programming, I'd highly recommend that you take some time to learn the basics of OO programming with C# first. You don't need to be an expert, but getting a basic understanding of the syntax and key concepts is going to go a long way to avoiding frustration. There's a FAQ here with some great recommendations.

    Hope that helps!
  • 5/13/2008 11:35 PM In reply to

    Re: Global Bool?

    I tried that and it still doesn't work
  • 5/14/2008 12:01 AM In reply to

    Re: Global Bool?

    You tried the FAQ to learn C# and it didn't work? ;)

    Seriously, I'm sure we can help you answer this question, but the question you're asking is very basic and has nothing to do with game development. You really should take sometime to sharpen your C# development skills some more. The question you're asking is a basic OO question, how do you make information in one class available to another. There are a few ways to do that and if you just spend a little time learning C# you'll learn several.

    I don't want to discourage you, but it's really hard to help answer game development questions when they're really, "how do I program" questions.
  • 5/14/2008 1:18 AM In reply to

    Re: Global Bool?

    George is right.  Take his advice and learn some object oriented programming with C# before you jump into making games.  It sounds pessimistic, but you won't get anywhere unless you learn the basics first.  Good luck!  :-)
  • 5/14/2008 1:05 PM In reply to

    Re: Global Bool?

    I have to add my agreement here as well. It sounds like you've come from a VB background and are trying to think VB in C#. It doesn't work. You'll need to learn how C# works before trying to code anything significant or you'll quickly become frustrated.
    Jim Perry - Microsoft XNA MVP
    If people spent a minute searching the forums and reading the FAQs before posting I'd be out of a job.
    Got some XNA Game Studio/XNA Framework development info to share with the community? Put it on the XNA Wiki.
    Please mark posts as Answers or Good Feedback when appropriate.
  • 5/16/2008 12:49 AM In reply to

    Re: Global Bool?

    ok I watched a couple of videos and they didn't help me at all. I have this line of code: player.Power += 1; and it's in one class but whenever I put it in the other class the game breaks and gives me an unhandled exception. I learn by modifying code so this will help me greatly. Please assist me! Thanks.
  • 5/16/2008 1:09 AM In reply to

    Re: Global Bool?

    We've assisted you as much as we can, the rest is up to you. Your questions are not game related. They are basic programming questions. Until you take the time to learn how to program using C#, you're going to continue to get stuck on simple questions like this. If you would just take a couple weeks, stop trying to do game development and just learn some basic development concepts, you would be far better off. But without that kind of effort on your part, there's not much the forums can do for you.
  • 5/16/2008 1:28 AM In reply to

    Re: Global Bool?

    You're not learning anything by modifying code. Just go to the library and start reading a C# introductory book, or check out the C# Workshop @ Gamedev.net.

    Until then, you are just wasting your time, no matter how much you bs yourself otherwise.
Page 1 of 1 (9 items) Previous Next