//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.Image = 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.ImageSize = new Vector2(picture.Width, picture.Height); layerList.Add(layer); }
//used to sort layers in Draw method public int CompareDepth(BackgroundLayer layer1, BackgroundLayer layer2) { //depth of 0 is closest, depth of 1 is furthest away if (layer1.Depth < layer2.Depth) { return(1); } if (layer1.Depth > layer2.Depth) { return(-1); } if (layer1.Depth == layer2.Depth) { return(0); } return(0); }