Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
coredump
Visitor

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 2
RokuJoel
Binge Watcher

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

Re: 2D API N00b question

Welcome to the 2D API Jungle! 8-)
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.