Exemplo n.º 1
0
 //used to sort layers in Draw method
 public int CompareDepth(BackgroundLayer layer1, BackgroundLayer layer2)
 {
     if (layer1.depth < layer2.depth)
         return 1;
     if (layer1.depth > layer2.depth)
         return -1;
     if (layer1.depth == layer2.depth)
         return 0;
     return 0;
 }
Exemplo n.º 2
0
        public void AddLayer(Texture2D picture, float depth, float moveRate)
        {
            BackgroundLayer layer = new BackgroundLayer();
            layer.picture = picture;
            layer.depth = depth;
            layer.moveRate = moveRate;
            layer.pictureSize.X = picture.Width;
            layer.pictureSize.Y = picture.Height;

            layerList.Add(layer);
            layerList.Sort(CompareDepth);
        }
Exemplo n.º 3
0
        //creates a layer from the data passed in and adds it to the list
        public void AddLayer(Texture2D picture, float depth, float moveRate)
        {
            BackgroundLayer layer = new BackgroundLayer();
            layer.picture = picture;
            //depth of 0 is closest, depth of 1 is furthest away
            layer.depth = depth;
            //if moveRate is positive, it will move right or down
            //if its negative, it will move left or up
            layer.moveRate = moveRate;
            layer.pictureSize.X = picture.Width;
            layer.pictureSize.Y = picture.Height;

            layerList.Add(layer);
        }