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: 
GPF
Visitor

Scrolling Bitmap off screen/region

When I have region.SetWrap(false) , and set an OffSet for the region should the bitnap scroll off the region/screen leaving the background color? Can someone post an example of this?

Thanks,
Troy
0 Kudos
5 REPLIES 5
GPF
Visitor

Re: Scrolling Bitmap off screen/region

This kind of does what I wanted. Except for once I move the sprite offset , it seems to change the offset of the region also so my DrawRect parameters are no longer valid but attached to the Sprite boundaries.


Library "v30/bslDefender.brs"

Function main()
black=&hFF'RGBA
screen=CreateObject("roScreen",false,640,480)
msgport = CreateObject("roMessagePort")
screen.SetPort(msgport)
codes = bslUniversalControlEventCodes()
compositor=CreateObject("roCompositor")
compositor.SetDrawTo(screen, black)
'bigbm=CreateObject("roBitmap","pkg:/images/temp.png")
bigbm=CreateObject("roBitmap",{width:640, height:480, AlphaEnable: false})
bigbm.DrawRect(0,0,640,480,&HFFFFFF)
region=CreateObject("roRegion", bigbm, 0, 0, 640,480)
region.SetWrap(false)
view_sprite=compositor.NewSprite(0, 0, region)
compositor.draw()
screen.Finish()
x=10:y=0
While True

msg=wait(0, msgport) ' wait for a button
If type(msg)="roUniversalControlEvent" Then
If msg.GetInt()=codes.BUTTON_RIGHT_PRESSED Then
region.DrawRect(0,0,10,480,Rnd(&HFFFFFF))
view_sprite.MoveOffset(x, 0)
compositor.draw()
screen.Finish()
region.SetPretranslation(0,0)
Else If msg.GetInt()=codes.BUTTON_LEFT_PRESSED Then
region.DrawRect(630,0,640,480,Rnd(&HFFFFFF))
view_sprite.MoveOffset(-x, 0)
compositor.draw()
screen.Finish()
region.SetPretranslation(0,0)
Else If msg.GetInt() = codes.BUTTON_BACK_PRESSED ' back button
Exit While
End If
End If
x=x+10
End While
End Function
0 Kudos
RokuJoel
Binge Watcher

Re: Scrolling Bitmap off screen/region

You created the sprite from the same roRegion you are drawing to with drawRect, so anything you draw to the roRegion should update the sprite. If you want them to be independent then you should base the sprite on a different bitmap and roRegion.

Can you provide a bit more detail as to what it is that you are trying to accomplish?

- Joel
0 Kudos
GPF
Visitor

Re: Scrolling Bitmap off screen/region

I am just trying to scroll my bitmap/region/sprite off the screen a couple pixels and have the other side show the clear background for the same couple of pixels on the opposite side. I still want the same bitmap to continue drawing to, without the offset. I could just redraw the entire background using DrawRect(x+Xshift,y,1,1,color) with an offset of a couple pixels but that would be very slow. Was trying to use either a region offset or sprite offset to accomplish this.

Thanks,
Troy
0 Kudos
GPF
Visitor

Re: Scrolling Bitmap off screen/region

So is this possible?

Thanks,
Troy
0 Kudos
RokuJoel
Binge Watcher

Re: Scrolling Bitmap off screen/region

I think what you really want to do is make a bitmap that has a transparant space in it, vertically, and set it to wrap. That way, when you offset it. it will show some of the background and still wrap around to the other side. Another approach would be to draw the same bitmap to the screen twice, with a gap, and when one moves off the screen, the other moves onto the screen.

- Joel
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.