This tutorial will cover how to create an Entity, which is the FRB term for a “game object”. Examples of entities include:
- Game characters (like Mario)
- Projectiles (like a bullet)
- UI elements (like a button)
- Text objects (like a score display)
Our first entity will be called “PlayerBall”.
To create an Entity:
- Right-click on the Entities tree item in Glue
- Select Add Entity
- Enter the name PlayerBall
- Check the Circle checkbox under the Collisions category. This will add a circle object to our entity, which we’ll use to test if the PlayerBall is touching the walls, goals, or other ball instances.
- Notice that the ICollidable checkbox is checked – we’ll cover this in a later tutorial. We’ll leave it checked for now.
- Click OK
Our entity will now be created and have a Circle under its Objects folder, as shown in the following image:
Alternative Approach – Adding a Circle
The previous section showed how to create an entity and add a Circle to the entity at the same time. Objects can be added after an entity is created as well. Note, the following steps are only shown for example, and do not need to be followed if you performed the previous steps.
To add a Circle to an already-created entity:
- Right-click on Objects
- Select “Add Object”
- Select the “FlatRedBall Type” option
- Select “Circle” in the list
- Enter the name “Body” and click OK
Viewing the Entity
At this point the PlayerBall entity can be previewed through the preview window (which is also called GlueView):
- Click the “Show Preview” checkbox
- If it isn’t selected, select the PlayerBall Entity and it will show in the preview window
At this point our project has a PlayerBall Entity which is ready to be used in a game. Of course, we haven’t yet created an instance of the newly-created Entity, so if you run your game you won’t see it (yet). The next tutorial will create a Screen which will contain our PlayerBall Entity.