Forum Discussion

GPF's avatar
GPF
Visitor
13 years ago

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
  • 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
  • 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
  • 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
  • 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