나는 나의 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>();
입니까?
목록이 초기화되었는지 확인 했습니까? – Ucodia
내가 게시 한 코드가 컴파일하려고하는 코드와 다른 것으로 의심됩니다. 즉, 같은 이름을 가진 두 개의 클래스가 있고, 모호성을 유발할 수있는 코드를 게시하지 않았습니다. 이유가 무엇이든, 컴파일러는'Trail' 클래스가 그것을 포함하는리스트보다 접근하기가 쉽지 않다고 생각합니다. 즉,리스트는 public 필드이고'Trail'은 private 클래스입니다. –