Roku SDK Documentation : SceneGraph BrightScript

Table of Contents


Two new BrightScript objects, roSGScreen and roSGNode, have been defined to allow our SceneGraph technology to be used in scripting.

BrightScript SceneGraph Scene Creation

Currently, a fairly strict ordering must be used in BrightScript to create a screen and set up its Scene node.

screen = CreateObject("roSGScreen")     ' create the roSGScreen
m.port = CreateObject("roMessagePort")     
screen.setMessagePort(m.port)
scene = screen.CreateScene("Scene")     ' create a Scene node
screen.show()                           ' display the screen 

roSGNode

The roSGNode object is the BrightScript equivalent of SceneGraph XML file node creation. To create an roSGNode object for a specific node class, call:

CreateObject("roSGNode", "nodetype")

Where nodetype is a string specifying the node class to be created. For example, the following creates an object of the SceneGraph Poster node class:

CreateObject("roSGNode", "Poster")

Reference information on all SceneGraph node classes can be found in SceneGraph API Reference.

Prior to creating an roSGScreen object and calling its show() function, creating roSGNode objects and using their interfaces is not guaranteed to work correctly. If you need to create some roSGNode objects and/or use roSGNode interfaces prior to calling an roSGScreen object show() function, you can use an roSGScreen object createScene() function to create an instance of a SceneGraph XML component that does any required setup and initialization prior to the roSGScreen object being displayed.

roSGScreen

The roSGScreen object is a SceneGraph canvas that displays the contents of a SceneGraph Scene node instance. The object is created by calling:

CreateObject("roSGScreen")

Typical Usage

CreateScene() takes one argument, the name of the scene component.  A channel will typically extend Scene to define its own channel specific Scene type (such as MyScene, etc.)  This Scene component name is passed to CreateScene().

roSGScreen Typical Usage Example
screen = CreateObject("roSGScreen")
scene  = screen.CreateScene("Scene")
screen.show()