Forum Discussion

gsarath's avatar
gsarath
Visitor
9 years ago

How to access the roSGScreen Object inside the Scene Graph Components

Is there a way how we can access the roSGScreen Object inside the Scene Graph Components.

Below mentioned is the code in Brightscript main.brs
sub Main()

    screen = CreateObject("roSGScreen")
    port = CreateObject("roMessagePort")
    screen.setMessagePort(port)

    m.scene = screen.CreateScene("VideoScene")
    screen.show()
     
    while(true)
        msg = wait(0, port)
        if type(msg) = "roSGScreenEvent"
            if msg.isScreenClosed() then return
        end if
    end while
end sub


VideoScene.xml
<?xml version="1.0" encoding="utf-8" ?>

<component name="VideoScene" extends="Scene">

<script type="text/brightscript" uri="pkg:/components/VideoScene.brs" />
</component>


VideoScene.brs
function init()

end function


Is there a way how we can get the roSGScreen object from the scene object inside VideoScene.brs similar to screen.GetScene()  which returns the roSGScene object associated with the screen.

2 Replies

  • I can think of couple of ways to pass roSgScreen into the scene - but why? 
    why would you want to do such a thing?!
  • I second EnTerr's question.  You can walk up the getParent() tree to get to the Scene from a component, but why would you ever need to get access to the roSGScreen?