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 N00b question

I am trying to learn the 2D API for a custom UI I am working on and can't get anything to draw on the canvas. What am I doing wrong ?

This is supposed to draw a solid yellow rectangle at the top of the screen


sub main()

screen = CreateObject("roScreen",true)
screen.DrawRect(0, 0, 1280, 121, &hFFFF00FF)
screen.Finish()

msgport = CreateObject("roMessagePort")
screen.SetMessagePort(msgport)

pressedState = -1 ' If > 0, is the button currently in pressed state

' Start our event loop

while true
if pressedState = -1 then
msg=wait(0, msgport) ' wait for a button press
else
msg=wait(1, msgport) ' wait for a button release or move in current pressedState direction
endif
if type(msg)="roUniversalControlEvent" then
keypressed = msg.GetInt()
print "keypressed=";keypressed
end if
end while

end sub
0 Kudos
2 Replies
Roku Employee
Roku Employee

Re: 2D API N00b question

You created a double buffered screen. You need to call swapbuffers() instead of Finish() on your screen.

- Joel
0 Kudos
Komag
Level 9

Re: 2D API N00b question

Welcome to the 2D API Jungle! 8-)
0 Kudos