2014-10-24 2 views
0

오히려 기본 Texture2D 이름 rect가 있고 그것을 초기화하려고합니다. 이 필드 이니셜 라이저가texture2d 사각형 XNA가 초기화되지 않습니다

 public class Game1 : Microsoft.Xna.Framework.Game 
{ 
    GraphicsDeviceManager graphics; 
    SpriteBatch spriteBatch; 

    //my variables and stuff I delcare 

    //texture we can render 
    Texture2D myTexture; 

    //set coords to draw the spirte 
    Vector2 spritePos = new Vector2(300.0f, 330.0f); 

    //some info about motion 
    Vector2 spriteSpeed = new Vector2(0f, 0f); 

    KeyboardState oldState; 
    double boost = 15; 

    //boost level rectange this is the issue below+ 
    Texture2D rect = new Texture2D(graphics.GraphicsDevice, 80, 30); 

    public Game1() 
    { 
     graphics = new GraphicsDeviceManager(this); 
     Content.RootDirectory = "Content"; 
    } 
+0

라인을'LoadContent' 메소드 (또는 그것이 호출 된 것)로 옮깁니다. – Athari

답변

2

Athari의 댓글이 정답이었다 비 정적 필드, 메서드 또는 속성 "그래픽"을 참조 할 수 없습니다라고 나에게 이야기한다 - 나는 LoadContent라는 방법

//boost level rectange this is the issue below+ 
    Texture2D rect = new Texture2D(graphics.GraphicsDevice, 80, 30); 

이동 () 그리고 그것은 효과가 있었다.

관련 문제