ok, so i'm working on creating the image in the middle of the viewport. To do this i am using the this.graphics.ToggleFullScreen() to set fullscreen, then attempting to use graphics.GraphicsDevice.Viewport.Height and width.
csharp
protected override void Initialize()
{
// TODO: Add your initialization logic here
player1 = new Player1();
this.graphics.ToggleFullScreen();
player1.setposition(graphics.GraphicsDevice.Viewport.Height, graphics.GraphicsDevice.Viewport.Width);
base.Initialize();
}
now the player1.setposition function takes in those two arguments and sets them equal to the Vector2 position:
csharp
private float positionwidth = 0;
private float positionheight = 0;
public Vector2 Position = new Vector2((positionwidth/2),(positionheight/2));
private Texture2D CardTexture1;
public void setposition(float inheight, float inwidth)
{
this.positionwidth = inwidth;
this.positionheight = inheight;
}
when i try and build it givies me the error
A field initializer cannot reference the nonstatic field, method, or property positionwidth and positionheight.
not sure exactly what it means.