Table of Contents

,

Start Page » DragonScript Scripting Language » Behavior Elements: Quick and Easy Development » ECBehaviorRenderableCamera

ECBehaviorRenderableCamera

Behavior element behavior adding a camera renderable.

To use this behavior add an ECBehaviorDynamicSkin to the element class before adding this behavior. Create ECBehaviorRenderableCamera behavior and set the dynamic skin and camera. Now you can add other behaviors targeting the ECBehaviorRenderableCamera to alter the renderable if desired.

Using a camera renderable or a canvas renderable with a render world canvas behaves differently. A render world canvas sets a fixed render size and allows to embed the camera view into other canvas to create elaborate results. A camera renderable does not force a specific render size. The graphic module is free to choose a resolution or to render the camera renderable directly. Render world canvas always renders into an image that can be reused. Camera renderables are usually more efficient and have better resolution since these requirements are not needed. On the other hand camera renderables prevent them to be embedded into canvas views. You need to use camera effects to add overlays or other manipulations. Nevertheless using camera renderable is faster and higher resolution and should be used unless complex canvas processing effects are required.

See also:

Instance Counts

Multiple ECBehaviorRenderableCamera instances can be added to affect individual dynamic skin textures.

Element Class Properties

Element class properties have the prefix renderableCamera. or renderableCamera({id}). if id is not empty.

renderable

Set renderable name. Renderable is created as camera type and the camera assigned.

Events

This behavior has no events.

Required Behaviors

Optional Behaviors

This behavior does not support optional behaviors.

Persistency

This behavior does not required element class to be persistable (setPersistable).

API Documentation

ECBehaviorRenderableCamera.

Since DragonScript Module Version 1.0

Use Cases

Element Class Example

This example defines an element which shows camera in dynamic skin.

class MyElement extends BehaviorElementClass
  public var ECBehaviorComponent component
  public var ECBehaviorCollider collider
  public var ECBehaviorDynamicSkin dynamicSkin
  public var ECBehaviorCamera camera
  public var ECBehaviorRenderableCamera renderableCamera
  func new()
    component = ECBehaviorComponent.new(this, null)
    collider = ECBehaviorCollider.new(this, component)
    dynamicSkin = ECBehaviorDynamicSkin.new(this, component)
    camera = ECBehaviorCamera.new(this, collider)
    renderableCamera = ECBehaviorRenderableCamera.new(this, dynamicSkin, camera)
  end
end

Behavior Factory

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='ECBehaviorComponent'/>
  <behavior type='ECBehaviorCollider'/>
  <behavior type='ECBehaviorDynamicSkin'/>
  <behavior type='ECBehaviorCamera'/>
 
  <behavior type='ECBehaviorRenderableCamera'>
    <!-- optional: use dynamic skin with id instead of empty string -->
    <string name='dynamicSkin'>second</string>
 
    <!-- optional: use camera with id instead of empty string -->
    <string name='camera'>second</string>
 
    <!-- set element properties. omit property prefix if used inside behavior tag -->
    <string name='.name'>value</string>
  </behavior>
 
  <!-- for adding multiple behaviors use unique identifiers -->
  <behavior type='ECBehaviorRenderableCamera' id='second'/>
</elementClass>

Live Examples