User Tools

Site Tools


dragengine:modules:dragonscript:abstractions

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
Next revisionBoth sides next revision
dragengine:modules:dragonscript:abstractions [2020/05/05 20:14] dragonlorddragengine:modules:dragonscript:abstractions [2020/05/05 20:23] dragonlord
Line 71: Line 71:
                  
         // create collider which is used for physical interaction. in most situations you want to         // create collider which is used for physical interaction. in most situations you want to
-        // animated the component with the rig. this requires to component behavior to go first+        // animate the component with the rig. this requires to component behavior to go first
         collider = ECBehaviorCollider.new(this, component)         collider = ECBehaviorCollider.new(this, component)
                  
         // create head lights. attached to collider with id "headlightLeft" respectively "headlightRight"         // create head lights. attached to collider with id "headlightLeft" respectively "headlightRight"
         headLightLeft = ECBehaviorLight.new(this, collider, "headlightLeft")         headLightLeft = ECBehaviorLight.new(this, collider, "headlightLeft")
-        headLightLeft.getLight().getColor().setColor(Color.YELLOW)+        headLightLeft.getLight().getColor().setColor(Color.yellow)
         headLightLeft.getAttach().getPosition().setVector(Vector.new(-1, 0.5, 2))         headLightLeft.getAttach().getPosition().setVector(Vector.new(-1, 0.5, 2))
                  
         headLightRight = ECBehaviorLight.new(this, collider, "headlightRight")         headLightRight = ECBehaviorLight.new(this, collider, "headlightRight")
-        headLightRight.getLight().getColor().setColor(Color.YELLOW)+        headLightRight.getLight().getColor().setColor(Color.yellow)
         headLightRight.getAttach().getPosition().setVector(Vector.new(1, 0.5, 2))         headLightRight.getAttach().getPosition().setVector(Vector.new(1, 0.5, 2))
                  
Line 93: Line 93:
                  
         // create behavior moving collider on rail. the mapper defines what rail to use.         // create behavior moving collider on rail. the mapper defines what rail to use.
-        // if you assign also the trigger system from the BaseGameApp then the mapper+        // if you assign also the trigger table from the BaseGameApp then the mapper
         // can use triggers to start/stop moving the train. if you want to control this         // can use triggers to start/stop moving the train. if you want to control this
         // on your own (or by other behaviors only) leave out this argument         // on your own (or by other behaviors only) leave out this argument
-        moveOnRail = ECBehaviorMoveOnRail.new(this, collider, BaseGameApp.getApp().getTriggerSystem())+        moveOnRail = ECBehaviorMoveOnRail.new(this, collider, BaseGameApp.getApp().getTriggerTable())
    end    end
 end end
 </code> </code>
  
-If you want to also add run-time behavior on top of the behavior without creating your own behavior 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:
 <code> <code>
 class MyTrainClass extends BehaviorElementClass class MyTrainClass extends BehaviorElementClass
Line 116: Line 116:
 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.
 ====== Scenery Elements: Customized and Optimized for Special Needs ====== ====== Scenery Elements: Customized and Optimized for Special Needs ======
  
dragengine/modules/dragonscript/abstractions.txt · Last modified: 2024/03/14 16:43 by dragonlord