Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
coredump
Visitor

2D API mixed with roku Screens

I am trying to go between a 2D screen and a built in roku screen (roSearchScreen). The code I wrote below demonstrates the concept and actually works, but intermediately it gets stuck on the search screen. Anyone know what I am doing wrong ?


Library "v30/bslCore.brs"

Function Main() As Void

device = CreateObject("roDeviceInfo")
displaySize = device.GetDisplaySize()

screen = CreateObject("roScreen", True)
msgport = CreateObject("roMessagePort")
screen.SetMessagePort(msgport)

compositor = CreateObject("roCompositor")
compositor.SetDrawTo( screen, &h000000FF )

overhangColorBmp = CreateObject("roBitmap", {width: displaySize.w, height: 121, AlphaEnable: false} )
overhangColorBmp.Clear ( RGBA_to_int( 232, 232, 73, 255) )

overhangregion = CreateObject("roRegion", overhangColorBmp, 0, 0, displaySize.w, 121)
compositor.NewSprite(0, 0, overhangregion)

compositor.DrawAll()
screen.swapbuffers()

codes = bslUniversalControlEventCodes()

' Start our event loop
while true
msg = Wait(0, msgport)
if type(msg) = "roUniversalControlEvent" then
keypressed = msg.GetInt()
if keypressed = codes.BUTTON_UP_PRESSED then

ShowSearchScreen()
print "Exited Search Screen"

compositor.DrawAll()
screen.swapbuffers()

end if
end if
end while

End Function

Function ShowSearchScreen() As Void

port = CreateObject("roMessagePort")
screen = CreateObject("roSearchScreen")
screen.SetMessagePort(port)
screen.Show()

' search screen main event loop
done = false
while done = false
msg = wait(0, screen.GetMessagePort())
if type(msg) = "roSearchScreenEvent"
screen.Close()
done = true
endif
endwhile

End Function

Function RGBA_to_int(R, G, B, A) As Integer

return &h1000000*R + &h10000*G + &h100*B + A

End Function
0 Kudos
1 REPLY 1
RokuJoel
Binge Watcher

Re: 2D API mixed with roku Screens

Try setting the return type to something other than void, and return a value


else if msg.isscreenclosed()
return -1 'or some value


when the search screen function closes.

Generally, it is best not to mix these screentypes, instead create a keyboard screen using the 2D API.

- Joel
0 Kudos