2011-10-09 3 views
0

나는 나의 Trail 클래스의 내 모든 인스턴스를 저장할 목록을 만들려고하지만, 그것은 나에게이 다음과 같은 오류주고있다 :C# XNA 목록 만들기?

Inconsistent accessibility: field type 'System.Collections.Generic.list<Jumper.Trail>' is less accessible than field 'Jumper.Main.trails'

나는 (이 erroring입니다) 코드의 다음 줄을 사용하고를 : 내가 잘못 뭐하는 거지

using System; 
using System.Collections.Generic; 
using System.Linq; 
using Microsoft.Xna.Framework; 
using Microsoft.Xna.Framework.Audio; 
using Microsoft.Xna.Framework.Content; 
using Microsoft.Xna.Framework.GamerServices; 
using Microsoft.Xna.Framework.Graphics; 
using Microsoft.Xna.Framework.Input; 
using Microsoft.Xna.Framework.Media; 

namespace Jumper 
{ 
    public class Trail 
    { 
     public int width; 
     public static float angle; 
     //The current position of the Sprite 
     public Vector2 pos = Vector2.Zero; 
     //The texture object used when drawing the sprite 
     public Texture2D trail; 

     public Trail() 
     { 
      angle = Player.rotation; 
      pos.X = Player.pos.X; 
      pos.Y = Player.pos.Y; 
     } 

     //Load the texture for the sprite using the Content Pipeline 
     public void LoadContent(ContentManager theContentManager, string theAssetName) 
     { 
      trail = theContentManager.Load<Texture2D>(theAssetName); 
     } 

     //Draw the sprite to the screen 
     public void Draw(SpriteBatch theSpriteBatch) 
     { 
      theSpriteBatch.Draw(trail, new Vector2(pos.X, pos.Y), Color.White); 
     } 

     public void updateTrail() 
     { 
     } 
    } 
} 

: 내 Trail.cs 코드는 여기

public static List<Trail> trails = new List<Trail>(); 

입니까?

+0

목록이 초기화되었는지 확인 했습니까? – Ucodia

+0

내가 게시 한 코드가 컴파일하려고하는 코드와 다른 것으로 의심됩니다. 즉, 같은 이름을 가진 두 개의 클래스가 있고, 모호성을 유발할 수있는 코드를 게시하지 않았습니다. 이유가 무엇이든, 컴파일러는'Trail' 클래스가 그것을 포함하는리스트보다 접근하기가 쉽지 않다고 생각합니다. 즉,리스트는 public 필드이고'Trail'은 private 클래스입니다. –

답변

1

private static List<Trail> trails = new List<Trail>();? 에서

0

A static class is basically the same as a non-static class, but there is one difference: a static class cannot be instantiated. In other words, you cannot use the new keyword to create a variable of the class type.

직접 인용 : http://msdn.microsoft.com/en-us/library/79b3xss3(v=vs.110).aspx

그래서 꽤 많이, 당신은 단지 정적 태그를 제거해야, 그게 전부입니다.

죄송합니다. = \