Introduction The ICollidable interface provides a standard collision implementation. Objects which implement ICollidable can collide with all FlatRedBall shapes and other ICollidables. The ICollidable interface requires a ShapeCollection property named Collision. FlatRedBall also offers the following extension methods for ICollidable: CollideAgainst – Simply returns true/false to indicate whether a collision has occured CollideAgainstMove – Returns[…]


Introduction The SortXInsertionAscending (and SortYInsertionAscending/SortZInsertionAscending) function can be used to sort all contained PositionedObjects in a list by their X (or Y/Z) value. Code Example The following code creates 3 Circles and places them in a PositionedObjectList in descending X order. Then SortXInsertionAscending is called, and the positions of the Circles are printed out: FlatRedBall.Math.PositionedObjectList<Circle>[…]


Introduction GetRandomPositionInThis returns a Vector3 representing a random position in the calling AxisAlignedRectangle. This value can be used for any logic, such as randomly positioning an object within an AxisAlignedRectangle. Code Example The following example can be used to create 50 Circles inside an AxisAlignedRectangle. The code assumes that the rectangle is called AxisAlignedRectangleInstance and[…]


Introduction CollideAgainstMove is a function which takes any shape type (such as AxisAlignedRectangle or Circle) and calls CollideAgainstMove between the argument and all shapes contained in the ShapeCollection. This method is an alternative to writing loops for all of the contained objects and manually calling CollideAgainstMove. Using CollideAgainstMove has a number of benefits: Less code[…]


Introduction The IVisible interface is an interface which defines that an object must have a Visible property. Setting Visible to true or false will make the object appear or disappear visually. Most visual FlatRedBall types implement the IVisible property including: Sprite Text AxisAlignedRectangle Circle Polygon SpriteFrame Code Example The following code shows how to toggle[…]


Introduction The Visible property on a Circle controls whether the Circle is rendered or not. Invisible Circles will still perform collision properly, so this property does not need to be set if using Circles purely for collision. Rendered circles will render their outline using their Color property. Circles cannot be filled-in, only their outline will[…]


Introduction 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 Circles and are implementing some spacial partitioning logic, you can use GetFirstAfter to find the index of the first Circle in a list to begin[…]


Introduction Sprite collision methods are obsolete! The Sprite collision methods were written long before Entities and Glue. During that time the Sprite was intended to contain its own collision; however, now the Entity pattern has replaced this approach. The collision methods in the Sprite class have been left in but instead we recommend using the[…]


Introduction The WorldXAt and WorldYAt methods are useful for finding the absolute world position of the Cursor at a given Z value. These methods should generally be used only when dealing with an unrotated Camera. For more information on limitations see below. If you are dealing with a 2D Camera (the default) then you can[…]


Introduction The DrawsShapes property can be used to control whether the Camera will render any shapes (such as Polygons and Circles). This is on by default, and can be turned off to hide all shape rendering. Common Usage Shapes are often used for collision, and their visible representation can be useful in debugging. Shapes can[…]