Error1Inconsistent accessibility: field type 'drag_and_lock_grid.Puzzlepiece[]' is less accessible than field 'drag_and_lock_grid.Game1.pieces'
This is the sentence that has the error shown:
public Puzzlepiece[] pieces;
This is my puzzlepiece class:
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
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;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;
namespacedrag_and_lock_grid
{
classPuzzlepiece
{
privateint id;
private Vector2 position;
private Vector2 previousPosition;
private Boolean dragging;
private Vector2 correctPosition;
private Texture2D texture;
private Boolean disabled = false;
private Texture2D plu;
private Vector2 lightUpPostion;
privateint delay = 3;
privateint delayTimer = 0;
privateint frame = 1;
private Boolean descending = false;
private Boolean stopAnimation;
publicPuzzlepiece(int id, Vector2 position, Texture2D texture, Vector2 correctPosition)
{
this.id = id;
this.position = position;
this.texture = texture;
this.correctPosition = correctPosition;
lightUpPostion = new Vector2(correctPosition.X - 5, correctPosition.Y - 5);
}
publicvoidDraw()
{
Game1.spriteBatch.Draw(texture, position, Color.White);
if (disabled)
{
if (!stopAnimation)
{
plu = Game1.content.Load("images/pieceslightup/plu_" + frame);
Game1.spriteBatch.Draw(plu, lightUpPostion, Color.White);
delayTimer++;
if (delayTimer > delay)
{
if (frame position.X && x position.Y && y correctPosition.X && x correctPosition.Y && y < correctPosition.Y + texture.Height)
{
returntrue;
}
returnfalse;
}
}
}
//public void addPoint()//{// if (!pointAdded)// {// Game1.noc++;// pointAdded = true;// }
And this is my Layer class which relies on the puzzlepiece class.
C#
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;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;
using Windows7.Multitouch;
namespacedrag_and_lock_grid
{
classLayer
{
// private int id;// private int length;// private int order;// private int overlappingg;privateint numberOfPieces;
privatestatic Layer instance;
privateint[] layers;
privateint[] tempArray;
private Boolean isOverlapping;
privateint[] Array;
privateint[] n;
privateint tempNumber = -1;
////// Singleton pattern///publicstatic Layer layerManager
{
get
{
if (instance == null)
instance = new Layer(12);
return instance;
}
}
publicLayer(int numberOfPieces)
{
this.numberOfPieces = numberOfPieces;
layers = newint[numberOfPieces];
tempArray = newint[numberOfPieces];
randomise();
}
publicvoidDraw()
{
//Game1.spriteBatch.Draw(texture, position, Color.White);
}
publicvoidUpdate()
{
}
publicvoidtouchDown(float x, float y, Puzzlepiece[] pieces)
{
// Then if you want to call the method useif(checkOverlap(x,y,pieces))
{
}
}
publicvoidtouchMove(float x, float y, Puzzlepiece[] pieces)
{
}
publicvoidtouchUp(float x, float y)
{
}
publicvoidrandomise()
{
for (int i = 0; i 1)
{
returntrue;
}
elsereturnfalse;
}
publicvoidmoveLayerToTop(int targetPuzzlePieces)
{
PuzzleP;
int tempArrayid;
int tempArrayitem;
int n;
for (int h = 1; h < totalpuzzlepieces; h++)
{
if (layers[h] = targetPuzzlePieces)
PuzzleP = h;
}
}
publicvoidpush(Puzzlepiece puzzlep)
{
for (int i = 1; i < PuzzleP; i++)
tempArray[i] = layers[i];
id[1] = puzzlep;
if (tempArray[i] != targetpuzzlepiece)
{
tempArray[i] = array[i];
}
else
{
}
}
publicvoidcheckHighestLayer()
{
for (int i = 1; i < PuzzleP; i++)
if (Puzzlep = overlapping)
{
puzzle p = array[n]; n++;
//the first one is to store the overlapping pieces
}
for (int i = 1; i < PuzzleP; i++)
if (Array[i] = layersArray[i])
{
}
else
{
}
}
}
}
Thank you for spending your precious time with me! :)
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Sam HobbsRank #108 · 20.5K reputationPosted Jul 3, 2010, 1:39 AM EDT
0
I think the error is the result of a derived class being more accessble than the base class. I hope you hav solved this already. If not, then just look at the accessibility of the drag_and_lock_grid.Puzzlepiece and drag_and_lock_grid.Game1 fields and you will figure it out.
Sam HobbsRank #108 · 20.5K reputationPosted Jul 3, 2010, 1:39 AM EDT