Hey Roku Dev Community,
I'm developing a channel with multiple roScreen's to create custom screens with animation provided by sprites. The issue I'm facing is safely passing off between roScreens. I've made attempts that have either resulted in
stack overflow and crashing
inconsistent screen output, randomly returning a blank screen
a complete disaster when attempting to pass off between a double buffered roScreen and another
I know this is easily achieved with template screens by waiting for
msg.isScreenClosed()
indicating the screen has safely closed, then exiting a while true loop, but a similar feature is missing for roScreen.
I have successfully handled passing between single buffered roScreens
Function Main() as void
screen = CreateObject("roScreen", false) ' single buffered roScreen
screen.Clear(&h662D9100 + 255) 'Roku Purple
screen.SetAlphaEnable(True)
port = CreateObject("roMessagePort")
screen.SetMessagePort(port) 'send events to port
catBackground = CreateObject("roBitmap", "pkg:/images/cat-1280x720.jpg")
if type(catBackground) = "Invalid"
print "type(catBackground) = Invalid"
end if
' update screen
screen.DrawObject(0, 0, catBackground)
screen.Finish()
'screen.Clear(&h0000FF00 + 255) ' clear screen for new frame, colourBlue on screen will indicate error
print "displaying cat"
' user input
while true
message = wait(0, port) ' get a message, if available
if type(message) = "roUniversalControlEvent" then
buttonAction = message.GetInt()
'print buttonAction
if (buttonAction = 0) then
' back button - close screen
print "------ Closed ------"
return
else if (buttonAction = 10) then
' Info/Options button (*)
print "* Button Pressed - leaving cat"
Lion()
print "Returned to cat"
screen.DrawObject(0, 0, catBackground)
screen.Finish()
endif
endif
end while
End Function
Function Lion() as void
lionBackground = CreateObject("roBitmap", "pkg:/images/lion-1280x720.jpg")
if type(lionBackground) = "Invalid"
print "type(lionBackground) = Invalid"
end if
screen = CreateObject("roScreen", false)
screen.Clear(&h662D9100 + 255) 'Roku Purple
screen.SetAlphaEnable(True)
port = CreateObject("roMessagePort")
screen.SetMessagePort(port) 'send events to port
' update screen
screen.DrawObject(0, 0, lionBackground)
screen.Finish()
'screen.Clear(&hFF000000 + 255) ' clear screen for new frame, colourRed on screen will indicate error
print "displaying lion"
' user input
while true
message = wait(0, port) ' get a message, if available
if type(message) = "roUniversalControlEvent" then
buttonAction = message.GetInt()
'print buttonAction
if (buttonAction = 0) then
' back button - close screen
print "------ Closed ------"
return
else if (buttonAction = 10) then
' Info/Options button (*)
print "* Button Pressed - leaving lion, returning to main()"
' print "screen = Invalid"
' screen = Invalid
exit while
endif
endif
end while
End Function
However when implementing with double buffered roScreens, it adds an extra layer of complexity.
I'm looking for a way to efficiently handle the transition between multiple double buffered roScreens. Any help is greatly appreciated.