Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
The KeepThisInsideOf method repositions the calling AxisAlignedRectangle (or its TopParent if it is attached to another PositionedObject) so that it is not outside of the argument AxisAlignedRectangle. This method will do a one-time re-position of the calling instance, so it must be called every frame if the moving AxisAlignedRectangle.
This method can only be used to keep AxisAlignedRectangles inside of other AxisAlignedRectangles - other shapes are not supported.
The AxisAlignedCube is a geometric shape from the FlatRedBall.Math.Geometry class. As a 3D shape, it can be used for detecting collisions with 3D or 2D shapes. The AxisAlignedCube class shares many similarities with other shape classes (Circle, Line, AxisAlignedRectangle, Polygon, etc). For general information about shapes, see the ShapeManager wiki entry.
AxisAlignedCubes are created through the ShapeManager. The following code creates an AxisAlignedCube through the ShapeManager and resizes it: Add the following using statement using FlatRedBall.Math.Geometry; Create the instance globally AxisAlignedCube mCube; In the Initialize method
For detecting collisions with AxisAlignedCubes, use the following code: Add the following using statement
Create the instance globally
In the Initialize method before the base call
In the Update method before the base calls
When two AxisAlignedCubes collide the collision side can be determined rather easily. The following code determines the side that two rectangles collided on: Add the following using statements
Assuming cube1 and cube2 are valid AxisAlignedCubes:
Did this article leave any questions unanswered? Post any question in our forums for a rapid response.
AxisAlignedRectangles are created through the ShapeManager. The following code creates an AxisAlignedRectangle through the ShapeManager and resizes it: Add the following using statement
Create the instance:
Add the following at class scope:
Add the following in Initialize after Initializing FlatRedBall:
Add the following in Update:
Alternatively, you can create an AxisAlignedCube with the Visible property set first by doing this Create the instance globally AxisAlignedCube mCube = ShapeManager.AddAxisAlignedCube();
The AxisAlignedRectangle is a which is used for unrotated bounding box collision. This is preferred over collision if Sprites are not rotated due to speed and memory usage considerations. AxisAlignedRectangles share many similarities with the other shape classes (, , and ). For general information about shapes, see the . For information on using AxisAlignedRectangles in Glue, see . AxisAlignedRectangles do not support being filled-in. They can only render as an outline. To render a solid rectangle, look at using with the
The "AxisAligned" part of AxisAlignedRectangle indicates that the sides of the rectangle are "axis aligned". In other words, the top, bottom, left, and right are all parallel to either the X or Y axes. AxisAlignedRectangles are always axis aligned for performance reasons. Therefore, if you rotate an AxisAlignedRectangle (set its RotationZ), this will have no impact on the collision behavior or its visible representation. If your game requires rotation, you should use the class. Of course, performance will suffer slightly if collision performance is a consideration for your game. For more information on axis alignment and a discussion of axis aligned object rotation and children positions, see .
The AxisAlignedRectangle class inherits from PositionedObject. This means that all properties which are available to (excluding rotation) are available to AxisAlignedRectangles. For more information, see the .
See .
Solid or moving collision can be performed with AxisAlignedRectangles as well as and . The following code creates three AxisAlignedRectangles - one controlled by the player, one which can be pushed, and one which is is immovable. Add the following using statements:
For information on determining which side an object has collided on, see .
Did this article leave any questions unanswered? Post any question in our for a rapid response.
GetRandomPositionInThis returns a 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.
The following example can be used to create 50 inside an AxisAlignedRectangle.