I’m doing a simple game and I got stucked at this : ( XNA, Visual basic 2010 )
I have a main class called Game1 with list of all walls ( for example )
And a second class Ball. I am doing collision detection in the ball class.
I need to access to the list of walls from the Game1 class, but i don’t know how, there is no instance of the Game1 class yet, and I don’t know the name of it.
Hope the explanation is clear enough.
The
Game1class is instanced by theProgramclass. While constructing your ball class, you can pass your game to the ball in the constructor.If you only want to pass the list of walls, maybe consider a class called
WallManagerof some sort and pass THAT to your ball class, instead of the whole game.Edit:
Or if your class is a
GameComponent, you can ask theGameof the component. But this is less nice, because you also need to conform to adding your ball instance to the components of the game and and supply an update function. And you have to cast your Game to a Game1.Example: