I want to set an image to fit the screen width and is able to scroll the image by using the 'up' and 'down' keys on the remote. I found this example code for scrolling a bitmap but it just displays the black screen. When i press the Home button on the remote it briefly displays the image for a split second but then the program exits and goes back to the Roku menu. What am i missing or doing wrong with this example code? The only thing i've changed from the original code is the image path.
function main()
black=&hFF 'RGBA
screen=CreateObject("roScreen")
compositor=CreateObject("roCompositor")
compositor.SetDrawTo(screen, black)
bigbm=CreateObject("roBitmap","pkg:/images/Image1.jpg")
region=CreateObject("roRegion", bigbm, 0, 0, 1280, 720)
region.SetWrap(true)
view_sprite=compositor.NewSprite(0, 0, region)
compositor.draw()
msgport = CreateObject("roMessagePort")
screen.SetMessagePort(msgport)
codes = bslUniversalControlEventCodes()
while true
msg=wait(0, msgport) ' wait for a button
if type(msg)="roUniversalControlEvent" then
if msg.GetInt()=codes.BUTTON_UP_PRESSED then
Zip(view_sprite, compositor, 0,-4) 'up
else if msg.GetInt()=codes.BUTTON_DOWN_PRESSED then
Zip(view_sprite, compositor, 0,+4) ' down
else if msg.GetInt()=codes.BUTTON_RIGHT_PRESSED then
Zip(view_sprite, compositor, +4,0) ' right
else if msg.GetInt()=codes.BUTTON_LEFT_PRESSED then
Zip(view_sprite, compositor, -4, 0) ' left
else if msg.GetInt() = codes.BUTTON_BACK_PRESSED ' back button
exit while
end if
end if
end while
end function
function Zip(view_sprite, compositor, xd, yd)
for x=1 to 60
view_sprite.OffsetRegion(xd, yd, 0, 0)
compositor.draw()
end for
end function