Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
AxisAlignedRectangles are rectangular shapes which cannot be rotated. AxisAlignedRectangles can be used as collision objects. For information on using AxisAlignedRectangles in code, see the AxisAlignedRectangle code page.
To add an AxisAlignedRectangle to an entity:
Expand your entity
Right-click on the Objects item
Select "Add Object"
Enter the name "Collision"
Set the SourceType to "FlatRedBallType
Objects in Screens and Entities can be of type Camera. A Camera object will (by default) represent the main Camera (FlatRedBall.Camera.Main). If an object in an Entity is a Camera, then this will (by default) attach the main Camera to the Entity. If an object in a Screen is a Camera, then this object serves as an alias for FlatRedBall.Camera.Main, but no attachment occurs.
Cameras added to a Screen can be modified in the FlatRedBall Editor. By default, adding a Camera object to a Screen does not create a new Camera, but rather it provides access to the main Camera. For more information, see the IsNewCamera property below. To access the camera in a Screen:
Select the Screen to contain the object. To make changes for all levels, select the GameScreen.
Click the Add Object button to add a new object to the screen
Select Camera as the type and click OK
The new camera appears in the GameScreen. It can be modified to make changes to the game, including in edit mode. For example, the Background Color can be changed from Black to any desired color.
The IsNewCamera property is a property which only appears on objects which are of type Camera.
If this property is false (the default value) then the Camera object is assigned to the main Camera (FlatRedBall.Camera.Main).
If this property is true, Glue will create a new Camera instance. This is not often used but can be used for split-screen games.
If you are developing a game which requires logic for initializing or controlling the Camera then you may want to organize this code into an Entity. The Camera object facilitates setting this up in Glue. The process is as follows:
Create an Entity which will contain all of the logic. For example an Entity named CameraEntity
Right-click on the CameraEntity's objects and add a new object
Select Camera as the type
Now you can code logic in the CustomInitialize and CustomActivity of your CameraEntity.
The Circle object is commonly used for collision and as a placeholder graphic in game development. Circles can be added to entities which implement the ICollidable interface to act as the entity's collision shape.
To add a circle to an existing entity:
Expand the entity
Right-click on the entity's Objects folder
Select Add Object
Verify the FlatRedBall or Custom Type option is selected
Select Circle
Click OK
Circles can also be added to a new entity. To do this:
Right-click on Entities
Select Add Entity
Check the Circle option. Notice that this automatically checks the ICollidable check box.
Set the SourceClassType to "AxisAlignedRectangle"
PositionedObjectLists (also referred to as lists) in the FlatRedBall Editor hold lists of objects which inherit from the PositionedObject type. Positioned objects include:
Any Entity (the most common types of lists)
Circles
AxisAlignedRectangles
Texts
Sprites
In code all of the objects mentioned above inherit from the FlatRedBall.PositionedObject class.
The most common place for lists is in GameScreen, although lists can exist in any screen and even in other entities.
As shown below, when an entity is created, the FlatRedBall suggests creating a list in GameScreen as well as adding a factory for the list. This configuration enables the following common and useful behaviors and relationships:
Entity lists automatically associated themselves with factories, so that creating a new instance through a factory in code results in the instance being added to the list.
Entity lists call Activity on all contained instances, keeping activity behavior consistent whether the instance is created in the FRB editor or at runtime (such as through a factory)
Entity lists automatically destroy all instances when the screen ends, making screen cleanup easy
By default the FRB Editor creates lists for newly-created entities if the default options are left unchanged. For example, the following animation shows the creation of an entity called Enemy which also results in an EnemyList added to GameScreen.
The FlatRedBall Editor provides a number of ways to create new lists.
If your game has a GameScreen, and if your GameScreen does not already contain a list for an entity, then the Quick Actions tab shows a button to add a list to the GameScreen. Clicking this button creates a new list in the GameScreen.
Entity lists can be created by right-click drag+dropping an entity into a screen. This is useful if you are adding lists of entities to screens other than the GameScreen.
PositionedObjectLists can also be created through the regular right-click menu in an screen or entity's Objects node:
Right-click on Objects
Select Add Object
Make sure FlatRedBall or Custom Type is selected
Select PositionedObjectList<T>
Select the type of list to create using the dropdown
Enter the name of the list
Once a list has been created, instances of the list's type can be added through the FRB Editor using a number of methods.
Option 1 - Drag+drop onto Screen, Objects folder or List
If a list contains a screen, it becomes the default container for newly-created instances that are added by drag+drop. For example, the following shows enemies being added to the EnemyList by drag+dropping an enemy on Level1, Level1's Objects folder, and directly on the EnemyList.
Option 2 - Right-click, Add Object
Objects can be directly added to the list by right-clicking on the list. Notice that the Add Object window restricts the types of entities which can be added to the types that are supported by the list. For example, the following animation shows how to add an Enemy to an Enemy list with the right-click menu.
If the list is of a base type, then the right-click option provides all available options for the list. For example, the following is a screenshot from a game which has multiple entity types inheriting from Enemy:
The CallActivity property controls whether the FRB Editor should generate Activity calls for a PositionedObjectList. By default this value is set to true. For example, the following shows a BulletList inside a screen which has its CallActivity set to true:
If this value is changed to false, then the Bullet instances inside of BulletList would not have their Activity (and CustomActivity) methods called automatically in generated code.
The most common reason to set this value to false is when dealing with derived entity lists. For example, consider a game which has a base Enemy entity as well as Skeleton entity which inherits from Enemy (Skeleton is an Enemy variant). If the game needs to perform custom logic on Skeleton instances then it may need both an EnemyList and SkeletonList in GameScreen.
In this case, Skeletons which are created through the Skeleton factory would be added to both the EnemyList and the SkeletonList. If both EnemyList and SkeletonList called Activity, then Skeleton instances would have activity called twice per frame. This can result in unexpected behavior such as movement logic being applied twice per frame.
If a derived entity type list is added to a screen through the quick action button, FlatRedBall automatically sets CallActivity to false.
If an entity list is added through the right-click option on a screen, FlatRedBall provides suggestions about whether to call Activity.
The Is2D option can be used to make a Layer use 2D coordinates. Layers which are 2D can be used even if the current Camera is in 3D. Layers which are 2D are often used to create HUDs and UI Screens.
For information on how to use Layers in code, see the Layer reference page.
The most common usage of the Is2D property is to create a 2D layer in a game which uses a 3D camera. Typically 3D games will have some type of 2D hud, so a 2D layer is needed to hold hud.
This example shows a simple setup where a 2D layer can be used on a 3D graphic. First, the game is set up to use a 3D camera.
Next, a Sprite is added to a GameScreen. It has the following variable values:
Texture = GroundTexture
Right Texture Pixel = 512
BottomTexturePixel = 512
Texture Address Mode = Wrap
Y = -10
Rotation X = 1.5708
The GameScreen has a layer named Layer2D for 2D objects.
Finally the GameScreen has a Text instance called GameOverText which has been placed on Layer2D.
The result is SpriteInstance is drawn in 3D, but the GameOverText is drawn and positioned in 2D.
The TileNodeNetwork object type is used to define the walkable areas in a level. Once a TileNodeNetwork is created it can be used for pathfinding for AI-controlled entities such as Enemies.
The FlatRedBall Editor supports the creation and population of TileNodeNetworks. Typically TileNodeNetworks are filled using tile maps. This section covers common ways to fill a TileNodeNetwork. We recommend using the GameScreen and Level approach, as this makes it easier to maintain games with multiple levels. Using this pattern, a TileNodeNetwork would be defined in the GameScreen:
Select the GameScreen
Click Add Object to GameScreen in the Quick Actions tab
Select TileNodeNetwork as the type
Enter a name for your TileNodeNetwork such as WalkingNodeNetwork
Click OK
Be sure to create the TileNodeNetwork in the GameScreen so it is included in all levels.
TileNodeNetworks (just like normal NodeNetworks) must have nodes and links to be used for pathfinding. Each node represents a point on the map where an entity can walk. These nodes are connected by links which indicate how an entity can walk.
We can create nodes and links for each level from the tiles in our Tiled map. We have two options for doing this:
By indicating that all empty tiles in a map should contain nodes
By using a dedicated tile for marking where entities can walk
The first option is easier because it works for many simple maps without any modifications. The second option provides more flexibility.
For simplicity we'll use the first approach (empty tiles):
Select the new TileNodeNetwork
Click on the TileNodeNetwork Properties tab
Click the From Layer option under the Creation Options category
Select your map and the layer. Typically this is Map and GameplayPlay layer.
Verify the All Empty option is selected
Optionally you may want to make the TileNodeNetwork visible so you can verify that it has been filled in:
Select the TileNodeNetwork
Click the Variables tab
Check the Visible checkbox
The game should display the node network wherever no tiles are present.
Some games include specific tiles for pathfinding rather than all empty tiles. The first step is to determine which tile to use as walkable tiles. Whichever tile is used should have its Class (or Type if using older versions of Tiled) specified in the tileset in Tiled.
Once this tile Type is set (and the .tsx is saved), this tile can be used to mark walkable areas in the map.
To use these tiles:
Select the TileNodeNetwork
Click the TileNodeNetwork Properties tab
Check the From Type property
Select the Source TMX File (usually Map)
Select the type for the tile you just saved. It should appear in the drop-down if the .tsx file has been saved.
The TileNodeNetwork will now place a node wherever the walkable tiles are present.
The FlatRedBall Editor supports creating objects of type ShapeCollection.
Note that entities which are created as ICollidable automatically have a ShapeCollection named Collision, and all shapes shapes are added to the default Collision shape collection. In this case you do not need to manually create a ShapeCollection. For more information, see the Implements ICollidable page.
To add a ShapeCollection:
Right-click on Objects under a Screen or Entity
Select Add Object
Verify that FlatRedBall or Custom Type is selected.
Select ShapeCollection
Click OK
Note that FlatRedBall also supports the .shcx file format, but this is no longer recommended. The PolygonEditor tool is no longer maintained, and the recommended approach is to add a ShapeCollection as shown above and to modify the shapes using FlatRedBall's LiveEdit.
ShapeCollections can have shapes added manually. The ShapeCollection serves as a "list" of shapes, but unlike normal lists, the ShapeCollection can contain multiple types of objects.
To add a new shape to the ShapeCollection:
Right-click on the ShapeCollection instance
Select Add Object
Select one of the shapes - notice that FlatRedBall filters the available types to the types allowed in a ShapeCollection.
Click OK
Your newly-created shape is added to ShapeCollection in the tree view.
For information on how to work with a ShapeCollection in code, see the ShapeCollection page.
A SoundEffectInstance is a sound effect which provides a number of properties which can be used to modify how the sound is played back - for example volume, pitch, and whether the sound is looping. If a SoundEffectInstance is playing, it cannot be played again until the sound ends, or until the SoundEffectInstance is explicitly stopped. This can give precise control over how many sounds are playing at one time.
To add a SoundEffectInstance to your project:
Make sure you have a Glue project with a Screen or Entity which will contain the SoundEffectInstance.
Add a new WAV file to your Screen or Entity. For more information, the .WAV file page.
At this point the SoundEffectInstance will be available in code, but you cannot change any variables on the SoundEffectInstance. To do this:
Right-click on Objects
Select "Add Object"
Select the "From File" option
Select the .wav file you added as a file
Click OK
Select the newly-created object
Change "SourceName" to "Entire File (SoundEffectInstance)"
Once the file has been added to Glue, you need to change the RuntimeType to SoundEffectInstance:
After setting up the object, you can modify the variables of the object in Glue. To do so, select the object and scroll to the "Unset Variables" category. These variables can also be set through code: