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:23] – [Examples] dragonlord | dragengine:modules:dragonscript:behavior_elements [2025/03/13 23:15] (current) – [XML Element Classes] dragonlord | ||
---|---|---|---|
Line 35: | Line 35: | ||
This is an example of an element class which which has a visual appearance, physical interaction, | This is an example of an element class which which has a visual appearance, physical interaction, | ||
+ | ++++ Show Example| | ||
< | < | ||
pin Dragengine.Gui | pin Dragengine.Gui | ||
Line 85: | Line 86: | ||
end | end | ||
</ | </ | ||
+ | ++++ | ||
The above script code creates a working element class which adds instances of BehaviorElement to the game world set up with the defined behaviors. If you want to have a unique element instance for your class to work with you can modify the code like this: | The above script code creates a working element class which adds instances of BehaviorElement to the game world set up with the defined behaviors. If you want to have a unique element instance for your class to work with you can modify the code like this: | ||
+ | ++++ Show Example| | ||
< | < | ||
class MyTrainClass extends BehaviorElementClass | class MyTrainClass extends BehaviorElementClass | ||
Line 102: | Line 105: | ||
end | end | ||
</ | </ | ||
+ | ++++ | ||
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. | ||
====== 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 519: | Line 531: | ||
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 529: | Line 542: | ||
</ | </ | ||
</ | </ | ||
+ | ++++ | ||
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 744: | Line 759: | ||
</ | </ | ||
</ | </ | ||
+ | ++++ | ||