Start Page » DragonScript Scripting Language » Behavior Elements: Quick and Easy Development » ECBehaviorBillboard
Behavior element behavior adding billboard support.
Billboards place a flat image in the game world optionally rotated towards the camera position.
This behavior can be added multiple times to an element. Use the behavior identifier to tell them apart.
Element class properties have the prefix billboard. or billboard({id}). if id is not empty.
Set path of skin resource to use.
<string name='billboard.skin'>billboard.deskin</string>
Set billboard axis. The billboard will be oriented along this axis if locked.
<vector name='billboard.axis' x='0' y='1' z='0'/>
Set billboard offset. The billboard will be placed with this offset relative to the origin. This is useful for elements like trees that should rotate along their base not their center. The offset is relative to the billboard size. Hence a value of 0.5 moves the billboard half its size.
<vector2 name='billboard.offset' x='0' y='0.5'/>
Set if billboard rotation is locked to billboard axis.
<boolean name='billboard.locked'>false</boolean>
Set if billboard rotation is spherical. If spherical the billboard rotates to face the camera origin. If not spherical the billboard is aligned with the camera looking direction. Spherical billboards get sheared near the border of the screen while non-spherical ones keep stay aligned with the screen.
<boolean name='billboard.spherical'>false</boolean>
Set if billboard size is fixed to the screen size. This causes the size of the billboard to stay the same relative to the screen no matter at what distance the billboard is seen. This is useful for billboards showing information to the player like status icons above a player. By fixing the size to the screen the status icons do not get larger and smaller if the actor approaches the screen or moves away from it.
<boolean name='billboard.sizeFixedToScreen'>true</boolean>
Set if billboard is rendered to environment maps.
<boolean name='billboard.renderEnvMap'>false</boolean>
This behavior has no events.
This behavior requires no other behaviors.
This behavior does not require the element class to be persistable (setPersistable).
Since DragonScript Module Version 1.0
This example defines an element which contain a billboard.
class MyElement extends BehaviorElementClass public var ECBehaviorCollider collider public var ECBehaviorBillboard billboard public func new() collider = ECBehaviorCollider.new(this) billboard = ECBehaviorBillboard.new(this, collider) billboard.getBillboard().getSkin().setPath("/content/billboards/tree.deskin") billboard.getBillboard().getOffset().setVector2(Vector2.new(0, 0.5)) end end
Using element class supporting adding behaviors the behavior can be added like this:
<?xml version='1.0' encoding='UTF-8'?> <elementClass name='MyClass' class='GenericBehaviorElement'> <behavior type='ECBehaviorBillboard'> <!-- set element properties. omit property prefix if used inside behavior tag --> <string name='.skin'>billboard.deskin</string> <vector2 name='.offset' x='0' y='0.5'/> </behavior> <!-- for adding multiple behaviors use unique identifiers --> <behavior type='ECBehaviorBillboard' id='second'/> </elementClass>