Jump to content
  • Advertisement
Sign in to follow this  
nobx101

Object created in one class, needs to use variables in the class it was created in

This topic is 909 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

I'm having a problem where I create a object of my Input class in my MainGame class, but the Input object needs to change multiple variables inside my MainGame class, how would I go about doing that?

 

Some things that I have though of so far are : 

 

  • Making the variable inside MainGame static - (Does not work since non-static functions need to use it)
  • Sending it to the Input constructor when I create it - (Prefer not to do this, since I would need to do this with multiple variables, causing a mess when creating the object)

So, any other ideas on how to fix this problem?

Share this post


Link to post
Share on other sites
Advertisement

Have the MainGame update itself based on state reported by the Input object?

 

Have the MainGame register callbacks on the Input object so the Input object can ask the MainGame to update itself?

 

Use a message-passing protocol to communicate state between object?

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!