我试图做一个列表,我的所有实例存储我Trail
类的,但它给我这个以下错误:C#XNA创建列表?
Inconsistent accessibility: field type 'System.Collections.Generic.list<Jumper.Trail>' is less accessible than field 'Jumper.Main.trails'
我用这下面的代码行(在那里示数):
public static List<Trail> trails = new List<Trail>();
这里是我的Trail.cs代码:
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()
{
}
}
}
我在做什么错?
您是否检查过您的列表是否已初始化? – Ucodia
我怀疑您发布的代码与您尝试编译的代码不同。那个,或者你有两个同名的类,并且你还没有发布足够的代码来澄清造成歧义的原因。不管是什么原因,你的编译器都认为'Trail'类不如包含它的列表可访问,即列表是一个公共字段,'Trail'是一个私有类。 –