This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
dragengine:modules:dragonscript:behavior_elements [2025/03/10 17:24] – [Examples] dragonlord | dragengine:modules:dragonscript:behavior_elements [2025/03/26 11:45] (current) – [Examples] dragonlord | ||
---|---|---|---|
Line 109: | Line 109: | ||
Using unique instances allows to add run-time features to your class on top of what BehaviorElement provides without creating an own behavior. In general it is recommended to work with behaviors only and creating your own ones. This way you can reuse game logic across different projects easily. | Using unique instances allows to add run-time features to your class on top of what BehaviorElement provides without creating an own behavior. In general it is recommended to work with behaviors only and creating your own ones. This way you can reuse game logic across different projects easily. | ||
+ | ====== Attachable Behaviors ====== | ||
+ | |||
+ | Attachable behaviors allow to add temporary behaviors to an element at runtime. They are similar in how the work to regular behaviors but instead of being added to # | ||
+ | |||
+ | Attachable behaviors implement # | ||
+ | |||
+ | Once added attachable behaviors can react to similar events like behaviors if they request it. Usually attachable behaviors react to onAddToElement() and onRemoveFromElement() to add or remove their effect to the parent element. | ||
+ | |||
+ | Attachable behaviors also are required to be persistable the same way as behaviors are. Hence attachable behaviors added to behavior elements are persisted in a future proof way as regular behaviors are. | ||
+ | |||
+ | Important to note is that attachable behaviors do not use the same interface as regular behaviors. This is on purpose since regular behaviors are split into ECBehavior and ECBehaviorInstance working together while ECAttachableBehavior is a standalone instance. | ||
====== XML Element Classes ====== | ====== XML Element Classes ====== | ||
+ | |||
+ | <WRAP center 100%> | ||
+ | <WRAP center box 1050px> | ||
+ | {{ youtube> | ||
+ | <WRAP centeralign> | ||
+ | Video explaining what behavior factories are, what they can be used for and how they are created. Shown using ExampleApp which contains an example for this.</ | ||
+ | </ | ||
+ | </ | ||
XML Element classes allow to create new element classes using an XML file ('' | XML Element classes allow to create new element classes using an XML file ('' | ||
Line 523: | Line 542: | ||
This example creates a simple XML element class based on the # | This example creates a simple XML element class based on the # | ||
+ | ++++ Show Example| | ||
<code xml> | <code xml> | ||
<?xml version=' | <?xml version=' | ||
Line 533: | Line 553: | ||
</ | </ | ||
</ | </ | ||
+ | ++++ | ||
This example creates a complex XML element class which is based on the # | This example creates a complex XML element class which is based on the # | ||
+ | ++++ Show Example| | ||
<code xml> | <code xml> | ||
<?xml version=' | <?xml version=' | ||
Line 748: | Line 770: | ||
</ | </ | ||
</ | </ | ||
+ | ++++ | ||