User Tools

Site Tools


dragengine:modules:dragonscript:behavior_elements

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
dragengine:modules:dragonscript:behavior_elements [2025/03/10 17:23] – [Examples] dragonlorddragengine: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, is animated, has two lights, has a speaker and moves along a rail. Basically this describes a kind of train running on a rail between two destinations. This is an example of an element class which which has a visual appearance, physical interaction, is animated, has two lights, has a speaker and moves along a rail. Basically this describes a kind of train running on a rail between two destinations.
  
 +++++ Show Example|
 <code> <code>
 pin Dragengine.Gui pin Dragengine.Gui
Line 85: Line 86:
 end end
 </code> </code>
 +++++
  
 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|
 <code> <code>
 class MyTrainClass extends BehaviorElementClass class MyTrainClass extends BehaviorElementClass
Line 102: Line 105:
 end end
 </code> </code>
 +++++
  
 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>heBLyt3b6G0?1000x591 }}
 +<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.</WRAP>
 +</WRAP>
 +</WRAP>
  
 XML Element classes allow to create new element classes using an XML file (''*.deeclass'') instead of writing script code. XML element classes always subclass from an existing script class or XML element class. Using an XML element class you can change properties added by the behavior definitions. XML Element classes allow to create new element classes using an XML file (''*.deeclass'') instead of writing script code. XML element classes always subclass from an existing script class or XML element class. Using an XML element class you can change properties added by the behavior definitions.
Line 519: Line 531:
 This example creates a simple XML element class based on the #@LinkApiDocDEDS2_HTML~classDragengine_1_1Scenery_1_1SimpleElementClass.html,SimpleElementClass~@#. It modifies some element properties to use a specific model, skin and rig resource. The path are either absolute path (if starting with ''/'') or relative to the directory the ''*.deeclass'' file is located in. This example creates a simple XML element class based on the #@LinkApiDocDEDS2_HTML~classDragengine_1_1Scenery_1_1SimpleElementClass.html,SimpleElementClass~@#. It modifies some element properties to use a specific model, skin and rig resource. The path are either absolute path (if starting with ''/'') or relative to the directory the ''*.deeclass'' file is located in.
  
 +++++ Show Example|
 <code xml> <code xml>
 <?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
Line 529: Line 542:
 </elementClass> </elementClass>
 </code> </code>
 +++++
  
 This example creates a complex XML element class which is based on the #@LinkApiDocDEDS2_HTML~classDragengine_1_1Scenery_1_1GenericBehaviorElementClass.html,GenericBehaviorElementClass~@#. This allows adding behaviors inside the ''*.deeclass'' file avoiding the need to write an explicit script class to do the same. This is the example file used in the behavior factory video above. This example creates a complex XML element class which is based on the #@LinkApiDocDEDS2_HTML~classDragengine_1_1Scenery_1_1GenericBehaviorElementClass.html,GenericBehaviorElementClass~@#. This allows adding behaviors inside the ''*.deeclass'' file avoiding the need to write an explicit script class to do the same. This is the example file used in the behavior factory video above.
  
 +++++ Show Example|
 <code xml> <code xml>
 <?xml version='1.0' encoding='ISO-8859-1'?> <?xml version='1.0' encoding='ISO-8859-1'?>
Line 744: Line 759:
 </elementClass> </elementClass>
 </code> </code>
 +++++
  
dragengine/modules/dragonscript/behavior_elements.1741627399.txt.gz · Last modified: 2025/03/10 17:23 by dragonlord