The GetFirstAfter value can be used to get the index of the next object after a given position value. For example, if you are working with a group of Entities (such as Enemy) and are implementing some partitioning logic, you can use GetFirstAfter to find the index of the first instance in a list to begin your loop for partitioning.
Note that if you are using CollisionRelationships and you have set up partitioning on your list, this method is automatically used internally to improve collision performance.
Assuming you have an already-sorted list of PositionedObjects, the following code can be used to get the first index after X = 0.
Typically GetFirstAfter is used to determine the starting index in a loop, such as in a collision loop. In this case you may want to adjust the lowBound value by half of the width of the type of object in the list. If your list has objects of varying size, you will want to use half of the width of the largest item.
GetFirstAfter is used in already-sorted lists, and it is usually used to insert new items in a PositionedObjectList such that the PositionedObjectList remains sorted after the insertion. The following code can be used to create 15 Sprites which will be inserted in order of their X value:
Add the following using statements:
Add the following to Initialize after initializing FlatRedBall: