3.6. Entities

What is an entity?

Entities are what make your game interactive. Each entity is a unique copy of an actor: it inherits all of the actor’s properties and program.

3.6.1. Creating Entities

At design time: When you drag an actor onto a scene, an entity of that actor is created. If you wish to create several entities quickly, you can select the Draw Tool.

  • Click the Draw button.
  • Select an actor.
  • Each time you click on the scene you will create an entity of the selected actor.

At run time: In many situations, we want entities to be created during the game. This can be achieved using the Entity Management commands. An entity can be programmed to create other entities. It can even set position, size, and other properties of the entities that it creates.

3.6.2. Copying Entities

You can copy an entity by holding down the Ctrl key and dragging a copy of it away from the original. The copied entity will inherit all of the properties from the entity you copy it from instead of its actor.

3.6.3. Entity’s properties

Each entity has its own properties such as its size, image, position, or shape. When an entity is created, it copies all the properties of its actor. But then those properties can be modified.

You can see these properties by clicking on an entity. An entity’s properties appear in the property editor.

3.6.4. Modifying Entity’s Properties

Design time:

You can easily move and resize entities on the scene. If you want to be more precise, you can set exact values in the Property Editor, you can also set all other an entity properties.

Run time:

Entities can change while the game is running. In an actor’s program, you can specify which properties of which entity you want to change.

A few notes:

  • Changing properties of an entity, either on the scene or through the program, does not affect properties of other entities, nor the properties of its actor.
  • Changing properties of an Actor does not affect the properties of existing entities on the scene. But any entities of that actor that are created from now on, will copy the new values for those properties. This includes both new entities created on the scene and through the program.

When a new entity is created using the program, and you need to change its properties to have a different value from its initial value (that is copied from its Actor’s properties), you can use the Create event to achieve that.

3.6.5. Removing an Entity

To remove an entity from the scene, click on the entity and press the Delete key. Use the Erase tool if you want to remove several entities quickly. After clicking the Erase button, every entity you click on will be removed.