Jump to content

Need help in solving this error!

- - - - -

  • Please log in to reply
No replies to this topic

#1
xuele91

xuele91

    Newbie

  • Members
  • Pip
  • 1 posts
Error 1 Inconsistent accessibility: field type 'drag_and_lock_grid.Puzzlepiece[]' is less accessible than field 'drag_and_lock_grid.Game1.pieces'

This is the statement that show the cause the error:
public Puzzlepiece[] pieces;

And this is the puzzlepiece class:
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;


namespace drag_and_lock_grid

{

     class Puzzlepiece

    {

        private int 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;

        private int delay = 3;

        private int delayTimer = 0;

        private int frame = 1;

        private Boolean descending = false;


        private Boolean stopAnimation;



        public Puzzlepiece(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);

        }


        public void Draw()

        {

            Game1.spriteBatch.Draw(texture, position, Color.White);


            if (disabled)

            {


                if (!stopAnimation)

                {

                    plu = Game1.content.Load<Texture2D>("images/pieceslightup/plu_" + frame);

                    Game1.spriteBatch.Draw(plu, lightUpPostion, Color.White);

                    delayTimer++;


                    if (delayTimer > delay)

                    {

                        if (frame < 3)

                        {

                            if (!descending)

                            {

                                frame++;

                                delayTimer = 0;

                            }

                        }

                        else

                            descending = true;


                        if (descending)

                        {

                            frame--;

                            delayTimer = 0;

                        }


                        if (frame == 0)

                        {

                            stopAnimation = true;

                        }

                    }


                }

            }


        }


        public void Update()

        {


        }


        public void touchDown(float x, float y)

        {

            //Game1.spriteBatch.GraphicsDevice.Clear(Color.White);

        }

        public void touchMove(float x, float y)

        {

            //if(!dragging)

            //{

            //    dragging = true;

            //    previousPosition.X = x;

            //    previousPosition.Y = y;

            //}

            if (!disabled)

            {

                if (isWithinPuzzle(x, y))

                {

                    position.X = x - (texture.Width / 2);

                    position.Y = y - (texture.Height / 2);

                }

            }


        }

        public void touchUp(float x, float y)

        {

            if (isWithinPuzzle(x, y))

            {

                if (isWithinCorrectPosition(x, y))

                {

                    position.X = correctPosition.X;

                    position.Y = correctPosition.Y;

                    disabled = true;

                    

                }

            }

            //dragging = false;

            //position.X = previousPosition.X;

            //position.Y = previousPosition.Y;

        }


        public Boolean isWithinPuzzle(float x, float y)

        {

            if (x > position.X && x < position.X + texture.Width && y > position.Y && y < position.Y + texture.Height)

            {

                return true;

            }

            return false;

        }


        public Boolean isWithinCorrectPosition(float x, float y)

        {

            if (x > correctPosition.X && x < correctPosition.X + texture.Width && y > correctPosition.Y && y < correctPosition.Y + texture.Height)

            {

                return true;

            }

            return false;

        }

    }

}

        //public void addPoint()

        //{

        //    if (!pointAdded)

        //    {

        //        Game1.noc++;

        //        pointAdded = true;

        //    }


        

And this is my Layer class which relies on the puzzle piece class.
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;


namespace drag_and_lock_grid

{

    class Layer

    {

        //  private int id;

        //    private int length;

        //      private int order;

        //        private int overlappingg;


        private int numberOfPieces;

        private static Layer instance;

        private int[] layers;

        private int[] tempArray;

        private Boolean isOverlapping;

        private int[] Array;

        private int[] n;

        private int tempNumber = -1;


        /// <summary>

        /// Singleton pattern

        /// </summary>

        public static Layer layerManager

        {

            get

            {

                if (instance == null)

                    instance = new Layer(12);


                return instance;

            }

        }


        public Layer(int numberOfPieces)

        {

            this.numberOfPieces = numberOfPieces;

            layers = new int[numberOfPieces];

            tempArray = new int[numberOfPieces];

            randomise();

        }


        public void Draw()

        {

            //Game1.spriteBatch.Draw(texture, position, Color.White);


        }


        public void Update()

        {


        }


        public void touchDown(float x, float y, Puzzlepiece[] pieces)

        {

          

// Then if you want to call the method use


            if(checkOverlap(x,y,pieces))

            {


           }

        }

        public void touchMove(float x, float y, Puzzlepiece[] pieces)

        {


            

        }


        public void touchUp(float x, float y)

        {


        }


        public void randomise()

        {

            for (int i = 0; i < numberOfPieces; i++)

            {

                layers[i] = -1;


                Boolean success = false;


                while (!success)

                {

                    tempNumber = Game1.random.Next(1, numberOfPieces + 1);


                    if (!repeatNumber(tempNumber))

                    {

                        layers[i] = tempNumber;

                        success = true;

                    }


                }

            }



        }


        public Boolean repeatNumber(int n)

        {

            foreach (int layer in layers)

            {

                if (n == layer)

                {

                    return true;

                }

            }


            return false;

        }


        public void print()

        {

            for (int n = 0; n < numberOfPieces; n++)

            {

                Console.WriteLine(n + "   " + layers[n]);

            }


        }


           public Boolean checkOverlap(float x, float y, Puzzlepiece[] pieces)

        {

            int count = 0;


            for (int i = 0; i < pieces.Length; i++)

            {

                if(pieces[i].isWithinPuzzle(x,y))

                {

                    count++;

                }

            

            }


            if (count > 1)

            {

                return true;

            }

            else

                return false;

        }

        public void moveLayerToTop(int targetPuzzlePieces)

        {

            PuzzleP;

            int tempArrayid;

            int tempArrayitem;

            int n;


            for (int h = 1; h < totalpuzzlepieces; h++)

            {

                if (layers[h] = targetPuzzlePieces)

                    PuzzleP = h;

            }


        }


          public void push(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

            {

            }


        }

          public void checkHighestLayer()

          {

              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 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users