Construct 2 Create Object for Every Spite in Family
Paid plans merely In Construct, Families are groups of object types. All the object types in a family must exist from the same plugin, e.g. all Sprite objects (and not a mix of Sprite and Tiled Background objects, for instance).
Families tin aid you lot avoid repeating events. For instance, instead of having the same events for the Enemy1, Enemy2 and Enemy3 objects, you can add together them all to an Enemies family and make the events in one case for the family unit. Then, the events automatically utilise to all the object types in the family unit.
The Families example in Construct demonstrates the advantage of this. At that place are vii kinds of enemy, and they all need to be destroyed when the light amplification by stimulated emission of radiation hits them. Without families, seven divide events are necessary, as shown below:
Using families all seven events tin can be replaced with a single event:
This makes it far easier to create and maintain projects with lots of objects that need to piece of work in like means.
How to create a family
Right-click the Families folder in the Projection Bar and select Add family. The Edit Family dialog appears.
Objects on the left are the objects in the project that can be added to the family. Objects on the correct are the objects already in the family. Double-click an object to transfer information technology to the other side. You can select multiple objects past belongings Command and clicking several objects, then clicking 1 of the buttons in the middle to transfer them.
When done, click OK and the family volition appear in the Project Bar. Information technology tin be expanded to show all the objects in the family every bit well. The family, and the objects in the family, can be edited past right-clicking them and choosing options from the menu, similar Remove from family unit or Edit family.
Objects can exist added to multiple families. All events for the object'south families will use to the object.
Family instance variables
Case variables can besides exist added to a whole family past correct-clicking the family unit name in the Projection Bar and selecting .
If you add together an instance variable to a family, all the object types in the family inherit the case variable. For case, adding the instance variable health to the family Enemies in the in a higher place example volition hateful BladeEnemy, BugEnemy, CrescentEnemy, FighterEnemy, SaucerEnemy, ScytheEnemy and SlicerEnemy all gain a health instance variable. Information technology volition also announced in the editor alongside each object's ain instance variables. However in the Outcome Sheet View the family volition only show its ain instance variables (those added directly to the family unit). This means any example variables y'all want to be available to the family's events must exist added to the family, and not to the objects in the family.
If an object type belongs to multiple families, it inherits every family's instance variables.
Family behaviors
Behaviors tin can also exist added to a whole family by right-clicking the family name in the Project Bar and selecting .
Equally with family unit instance variables, if you add together a behavior to a family, all the object types in the family inherit the beliefs. The behavior will appear in the events for all the objects in the family unit and the family unit itself. For case adding the Bullet behavior to a family called Bullets means the bullet's Set speed activeness is available to every object in the family, as well every bit the family itself.
If an object blazon belongs to multiple families, it inherits every family's behaviors.
Family furnishings
Effects tin can also exist added to a whole family by right-clicking the family name in the Project Bar and selecting .
As with family unit instance variables and behaviors, if you add an issue to a family unit, all the object types in the family inherit the result. This tin be useful for quickly applying effects to a number of different object types.
If an object type belongs to multiple families, it inherits every family's effects.
Picking families in events
Families pick instances in the event canvass independently of the object types in the family. For instance, consider Family1 consisting of SpriteA and SpriteB. Weather for Family1 will never affect which SpriteA and SpriteB instances are picked. It volition but touch on which instances are afflicted when running an action for Family1. Likewise, conditions picking SpriteA and SpriteB instances will never affect which instances are picked in Family1. In other words, in the effect sheet families are treated like an entirely separate object type, which just happens to accept instances from other object types. This can exist taken reward of if you demand a single consequence to pick two separate lists of instances from the same object type.
Upgrading ordinary objects to families
If y'all brand a lot of events forgetting to use a family and want to replace them, it's possible to apply the Replace Object feature to salvage you re-doing every event. The process is described in the tutorial How to upgrade an object to a family.
Summary
Families are a very powerful feature which are essential to assist proceed large projects simple. Instance variables and behaviors added to families are inherited by every object in the family, which allows for sophisticated logic to be hands applied to many object types at one time.
Source: https://www.construct.net/en/make-games/manuals/construct-3/project-primitives/objects/families
0 Response to "Construct 2 Create Object for Every Spite in Family"
Post a Comment