Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
Showing results for 
Show  only  | Search instead for 
Did you mean: 
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)

msgport = CreateObject("roMessagePort")

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
msg=wait(1, msgport) ' wait for a button release or move in current pressedState direction
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
Level 10

Re: 2D API N00b question

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