This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
dragengine:modules:dragonscript:abstractions [2020/05/05 20:14] – dragonlord | dragengine: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 | + | // animate |
collider = ECBehaviorCollider.new(this, | collider = ECBehaviorCollider.new(this, | ||
| | ||
// create head lights. attached to collider with id " | // create head lights. attached to collider with id " | ||
headLightLeft = ECBehaviorLight.new(this, | headLightLeft = ECBehaviorLight.new(this, | ||
- | headLightLeft.getLight().getColor().setColor(Color.YELLOW) | + | headLightLeft.getLight().getColor().setColor(Color.yellow) |
headLightLeft.getAttach().getPosition().setVector(Vector.new(-1, | headLightLeft.getAttach().getPosition().setVector(Vector.new(-1, | ||
| | ||
headLightRight = ECBehaviorLight.new(this, | headLightRight = ECBehaviorLight.new(this, | ||
- | headLightRight.getLight().getColor().setColor(Color.YELLOW) | + | headLightRight.getLight().getColor().setColor(Color.yellow) |
headLightRight.getAttach().getPosition().setVector(Vector.new(1, | headLightRight.getAttach().getPosition().setVector(Vector.new(1, | ||
| | ||
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 | + | // if you assign also the trigger |
// 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, | + | moveOnRail = ECBehaviorMoveOnRail.new(this, |
end | end | ||
end | end | ||
</ | </ | ||
- | If you want to also add run-time behavior on top of the behavior without creating | + | The above script code creates a working element class which adds instances of BehaviorElement to the game world set up with the defined behaviors. |
< | < | ||
class MyTrainClass extends BehaviorElementClass | class MyTrainClass extends BehaviorElementClass | ||
Line 116: | Line 116: | ||
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. | ||
====== Scenery Elements: Customized and Optimized for Special Needs ====== | ====== Scenery Elements: Customized and Optimized for Special Needs ====== | ||