loadContent 메서드 외부에서 아무 텍스처 나 인식되지 않는 문제가 있습니다."textureName"이 현재 컨텍스트에 존재하지 않습니다.
protected override void LoadContent()
{
spriteBatch = new SpriteBatch(GraphicsDevice);
Texture2D tileStart = Content.Load<Texture2D>("tile_start");
Texture2D tileCrossJunction = Content.Load<Texture2D>("tile_crossjunction");
Texture2D tileTJunction = Content.Load<Texture2D>("tile_t-junction");
Texture2D tileCorner = Content.Load<Texture2D>("tile_corner");
Texture2D tileHallway = Content.Load<Texture2D>("tile_hallway");
Texture2D tileDeadEnd = Content.Load<Texture2D>("tile_deadend");
Texture2D sqrPlayer = Content.Load<Texture2D>("sqr_player");
Texture2D sqrBaddieSmall = Content.Load<Texture2D>("sqr_baddie_small");
Texture2D sqrBaddie = Content.Load<Texture2D>("sqr_baddie");
Texture2D sqrBaddieLarge = Content.Load<Texture2D>("sqr_baddie_large");
}
이 방법 없음 문제,하지만 ... 내 그리기 방법이 텍스처 중 하나를 참조하려고 할 때이 오류가
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.DarkGray);
base.Draw(gameTime);
spriteBatch.Begin();
spriteBatch.Draw(tileStart, new Vector2(0,0), Color.White);
spriteBatch.End();
}
는 "tileStart는 현재 컨텍스트에 존재하지 않습니다 . "
일반적으로 tileStart
은 LoadContent
메서드 내에서 선언되는 변수이므로 다른 곳에서는 사용할 수 없으므로 인식되지 않는다고 말할 수 있습니다. 제가 혼란스러워하는 이유는 제가 읽은 모든 튜토리얼은이 정확한 문법을 보여 주며 그러한 경우에 잘 작동하는 것처럼 보입니다. 분명히 여기에 내가 이해하지 못하는 다른 것이 있습니다.
여러분이 제공 할 수있는 도움이 있으면 대단히 감사하겠습니다.
사용중인 튜토리얼에 대한 링크를 게시하는 경우이를 파악하려고합니다. 그 외, 위에 게시 한 코드가 정확한 경우 (내 대답 참조) 단순히 불가능합니다. – Colton