SetByDerived

Introduction

The SetByDerived property can allow base Entities to define that it contains a certain Object type which will be assigned in deriving Entities. Keep in mind that both the base and derived Object type must be the same. In other words, if the base Entity has a Sprite Object, then the Entity that derives from the base must also define the object as a Sprite (see below for example).

SetByDerived makes an object “null”

If you set the SetByDerived property on an object to true, that means that Glue will not create that object in the Screen or Entity that contains this Object. This Screen or Entity must be used as a base Screen or Entity to actually create an object.

For example, consider an Entity called Character which contains a Sprite Object with SetByDerived set to true. The Sprite will not be created if you add an instance of Character to another Screen or Entity. The Character must be used as a base for another Entity (such as an Entity called “Monster”).

Example

The following shows how to create an Entity (Base) which defines a Sprite Object which will get SetByDerived. The Derived then re-defines the Sprite.

Creating a Base Entity

  1. Right-click on the  tree item
  2. Select Add Entity

  3. Name the entity Base
  4. Check the Sprite checkbox to add a Sprite to the Base entity

  5. Click OK

Creating a Derived Entity

  1. Right-click on the Entities tree item
  2. Select Add Entity
  3. Name the entity Derived
  4. Click OK
  5. Click the Properties tab on the newly-created Derived entity
  6. Set the BaseEntity property Entities\Base

Base and Derived are bad names!
This example uses the names “Base” and “Derived” to clearly indicate the relationship between two Entities. In an actual game, avoid using names like Base and Derived. You should always name your Entities in a way to indicate what they are in the context of your game (such as Character or Enemy or PlayerShip). However, if you intend to use an Entity as a base type, it is a good idea to append “Base” at the end of the name (such as EnemyBase).

Setting SetByDerived to True

  1. Expand the Base entity
  2. Select SpriteInstance (which was created earlier when the Sprite checkbox was checked)
  3. Select the Properties tab
  4. Set the SpriteObject’s SetByDerived to True

Glue will automatically add a SpriteInstance to the Derived entity.

Specifying Properties on Derived Sprite

At this point the Derived entity will automatically create a Sprite for you (since it is an object in Glue). You can select this Sprite and assign variables on it, just like any other Sprite.