Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Search instead for 
Did you mean: 
coredump
Level 7

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
Roku Employee
Roku Employee

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