SFML community forums

Help => General => Topic started by: Geoffry_the_Deprogrammer on November 23, 2014, 01:31:08 am

Title: Anyone know about passing variables between classes in SFML C#...?
Post by: Geoffry_the_Deprogrammer on November 23, 2014, 01:31:08 am
I am attempting to pass a integer variable into another class, and get it to increase on a condition, the code itself doesn't seem to have any problem, until I run the program, at which point I am met with the error "Object reference not set to an instance of an object" does anyone know what I might be doing wrong...?
Title: Re: Anyone know about passing variables between classes in SFML C#...?
Post by: Gambit on November 23, 2014, 03:03:07 am
Sharing is caring (Please provide a complete and minimal code).
Title: Re: Anyone know about passing variables between classes in SFML C#...?
Post by: Geoffry_the_Deprogrammer on November 23, 2014, 04:09:16 am
is this sufficient...?

            if (correctLetter1 == true)
            {
                game.GatesCleared += 1;
            }
Title: Re: Anyone know about passing variables between classes in SFML C#...?
Post by: Hapax on November 23, 2014, 04:25:37 am
That's not exactly complete code. Complete code is code that can be copied, pasted, and compiled without modification. See this information (http://en.sfml-dev.org/forums/index.php?topic=5559.msg36368#msg36368).

Also, doing this, which you should have already done (http://bit.ly/UA4tt9), I found this:
Quote
When ever you try to retrieve data from a Null object you will get this error. Before retrieving the data from any object check for NULL.
Does it help at all?
Title: Re: Anyone know about passing variables between classes in SFML C#...?
Post by: Geoffry_the_Deprogrammer on November 23, 2014, 04:46:02 am
yeah, im not entirely sure what is and is not required... last time i posted a question i added too much code... im not sure how to gauge how much I need to show... none of my variables are null... im not entirely sure what the error message im getting actually means, even after hours of searching on the internet... i cant figure out what the error is...
Title: Re: Anyone know about passing variables between classes in SFML C#...?
Post by: Hapax on November 23, 2014, 07:16:19 am
im not entirely sure what is and is not required...im not sure how to gauge how much I need to show
When it comes to complete and minimal code, complete means that it should be easily copied, pasted, and compiled by others to test it, and minimal means that it should be code that only what is necessary to create the error. If something doesn't cause this error, it's irrelevant to the post and shouldn't be in the example code.
Title: Re: Anyone know about passing variables between classes in SFML C#...?
Post by: Nexus on November 23, 2014, 12:29:04 pm
This forum is about SFML, not about programming languages.

Please use a different platform (StackOverflow, C# forum) for language-specific questions that have nothing to do with SFML.