2014-11-26 1 views
0

저는 첫 번째 주요 프로젝트에서 C#으로 작업 해 왔으며 동일한 솔루션에있는 다른 C# 클래스 파일과 해당 네임 스페이스를 참조하려고했습니다.네임 스페이스를 참조하는 C# XNA 사용

정확한 오류는 '유형 또는 네임 스페이스 이름'theNamespace '을 (를) 찾을 수 없습니다'주위를 둘러 보았고 내 문제를 해결하는 것이 발견되지 않았습니다. 다음은 오류가 감지 된 위치에 초점을 맞춘 내 현재 코드의 요약 된 버전입니다.

namespace TileMap 
{ 
    public class MapRow 
    { 
     public int TileMap() 
     { 
      for (int y=0; y<MapHeight; y++) 
      { MapRow thisRow=new MapRow(); 
       for (int x=0; x<MapWidth; x++){ 
        thisRow.Columns.Add(new MapCell(0)); 
       } 
       Row.Add(thisRow); 
      }} 
     public List<MapCell> Columns = new List<MapCell>(); 
     public List<MapRow> Rows = new List<MapRow>(); 
     public int MapWidth = 50; 
     public int MapHeight = 50;   
     } 
} 

namespace tiles 
{ 
    static class tile 
    { 
     static public Texture2D TileSetTexture; 

     static public Rectangle GetSourceRectangle(int tileindex) 
     { 
      return new Rectangle(tileindex * 32, 0, 32, 32); 
     } 
    } 
} 

어떤 제안 멋진 것 다음과 같이 내가 전화하려고 해요

using TileMap.MapRow.NET; 
using tiles.tile.NET; 

namespace Project 
{ 
    public class Class1 { 
    Tilemap.MapRow.TileMap myMap = new TileMap(); 
    } 
    protected override void LoadContent() { 
    tile.tilesettexture=Content.Load<Texture2D>("@textures"); 
    } 
} 

클래스입니다.

+0

솔루션에 참조로 프로젝트를 추가 했습니까? –

답변

0

이해가되지 않는 선 Tilemap.MapRow.TileMap myMap = new TileMap(); 들어 있습니다. TileMap은 유형이 아니며 클래스 Tilemap.MapRow의 메소드입니다. 인스턴스를 생성 할 수 없습니다. 또한 TileMap.MapRow이 아니고 Tilemap.MapRow이 아니어야합니다 (자본금 M에 유의하십시오).

0

당신은

using TileMap; 
using tiles; 

를 사용하고 방법

MapRow myMap = new MapRow(); 
int i = myMap.TileMap(); 

에 액세스 할 때 정적 클래스

Rectangle r = tile.GetSourceRectangle(1); 
관련 문제