Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Anyone know about passing variables between classes in SFML C#...?  (Read 2327 times)

0 Members and 1 Guest are viewing this topic.

Geoffry_the_Deprogrammer

  • Newbie
  • *
  • Posts: 14
    • View Profile
    • Email
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...?

Gambit

  • Sr. Member
  • ****
  • Posts: 283
    • View Profile
Re: Anyone know about passing variables between classes in SFML C#...?
« Reply #1 on: November 23, 2014, 03:03:07 am »
Sharing is caring (Please provide a complete and minimal code).

Geoffry_the_Deprogrammer

  • Newbie
  • *
  • Posts: 14
    • View Profile
    • Email
Re: Anyone know about passing variables between classes in SFML C#...?
« Reply #2 on: November 23, 2014, 04:09:16 am »
is this sufficient...?

            if (correctLetter1 == true)
            {
                game.GatesCleared += 1;
            }

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Anyone know about passing variables between classes in SFML C#...?
« Reply #3 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.

Also, doing this, which you should have already done, 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?
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

Geoffry_the_Deprogrammer

  • Newbie
  • *
  • Posts: 14
    • View Profile
    • Email
Re: Anyone know about passing variables between classes in SFML C#...?
« Reply #4 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...

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Anyone know about passing variables between classes in SFML C#...?
« Reply #5 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.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Anyone know about passing variables between classes in SFML C#...?
« Reply #6 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.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

 

anything