public class Game1 : Microsoft.Xna.Framework.Game
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;
Ball pall;
MinuPad playerPad;
public int screenWidth;
public int screenHeight;
public Game1()
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
}
protected override void Initialize()
{
screenWidth = GraphicsDevice.Viewport.Width;
screenHeight = GraphicsDevice.Viewport.Height;
To get variable that stored screenHeight ( obvious right.. )
But I cant use the variable in different classes. For example I have a class called Ball.cs where I also need to use information about screenWidth and screenHeight.
When I try to use the same GraphicsDevice.Viewport.Width it gives me :
An object reference is required for the non-static field, method, or property 'Microsoft.Xna.Framework.Graphics.GraphicsDevice.Viewport.get'
My Question : Why cant I use GraphicsDevice.Viewport in other classes. What should I do to resolve the problem?

New Topic/Question
Reply


MultiQuote








|