Forum Discussion
bcoding
10 years agoVisitor
Drawing the text to bitmap and drawing the bitmap to screen when needed makes more sense. Thanks for these information. I will edit it later.
For now, I am confused in the scrolling region. If I increased the quantity of offers(here I have listed 12 offers), only the ones that fit inside the region are displayed and even if I scroll the remaining items are not displayed. I thought the remaining offers will be hidden somewhere downside and would appear once i scroll the region, but even if I scroll the same items that were displayed earlier keeps repeating.
What should I do inorder for my region to accomodate more items and display them when scrolling?
For now, I am confused in the scrolling region. If I increased the quantity of offers(here I have listed 12 offers), only the ones that fit inside the region are displayed and even if I scroll the remaining items are not displayed. I thought the remaining offers will be hidden somewhere downside and would appear once i scroll the region, but even if I scroll the same items that were displayed earlier keeps repeating.
What should I do inorder for my region to accomodate more items and display them when scrolling?
Library "v30/bslDefender.brs"
Function Main () AS void
'creating screen object
screen=CreateObject("roScreen",false)
screen.clear(&hff0000ff)
' font for the text
fontRegistry = CreateObject("roFontRegistry")
font = fontRegistry.GetDefaultFont(24,false,false)
'writing the text to the screen
screen.DrawText("Hi Customer",400,90, &h00FFFFFF ,font)
screen.DrawText("Your name is : John Doe",285,145,&h00FFFFFF,font)
screen.DrawText("__________________________________",400,180, &h00FFFFFF,font)
screen.DrawText("Here are your choices: ",270,225, &h00FFFFFF,font)
'creating compositor objects
compositor=CreateObject("roCompositor")
' compositor.SetDrawTo(screen, &hff0000ff)
compositor.SetDrawTo(screen,0)
'creaating bitmap and writing text to bitmap
srollBm=CreateObject("roBitmap",{ width: 650, height: 200, AlphaEnable: false })
srollBm.DrawText("1)Get a Macbook pro with 4GB ram and 250gb harddrive",0,0,&h00FFFFFF,font)
srollBm.DrawText("2)Get a Macbook pro with 8GB ram and 260gb harddrive",0,20,&h00FFFFFF,font)
srollBm.DrawText("3)Get a Macbook pro with 12GB ram and 270gb harddrive",0,40,&h00FFFFFF,font)
srollBm.DrawText("4)Get a Macbook pro with 14GB ram and 280gb harddrive",0,60,&h00FFFFFF,font)
srollBm.DrawText("5)Get a Macbook pro with 16GB ram and 290gb harddrive",0,80,&h00FFFFFF,font)
srollBm.DrawText("6)Get a Macbook pro with 18GB ram and 300gb harddrive",0,100,&h00FFFFFF,font)
srollBm.DrawText("7)Get a Macbook pro with 20GB ram and 310gb harddrive",0,120,&h00FFFFFF,font)
srollBm.DrawText("8)Get a Macbook pro with 22GB ram and 320gb harddrive",0,140,&h00FFFFFF,font)
srollBm.DrawText("9)Get a Macbook pro with 24GB ram and 330gb harddrive",0,160,&h00FFFFFF,font)
srollBm.DrawText("10)Get a Macbook pro with 26GB ram and 340gb harddrive",0,180,&h00FFFFFF,font)
srollBm.DrawText("11)Get a Macbook pro with 28GB ram and 350gb harddrive",0,200,&h00FFFFFF,font)
srollBm.DrawText("12)Get a Macbook pro with 30GB ram and 360gb harddrive",0,220,&h00FFFFFF,font)
'creating region that will be used for scrolling
region=CreateObject("roRegion", srollBm, 0, 0, srollBm.getwidth(), srollBm.getheight())'size of scroll area
region.SetWrap(True)
'this will create new sprite
view_sprite=compositor.NewSprite(370,400, region)
'draw the sprites created
compositor.drawAll()
screen.finish()
'creating port inorder to listen to user events
msgport = CreateObject("roMessagePort")
screen.SetMessagePort(msgport)
codes = bslUniversalControlEventCodes()
While True
msg=wait(0, msgport) ' wait for a button
print "Msg: "; type(msg); " event: "; msg.GetInt()
If type(msg)="roUniversalControlEvent" Then
If msg.GetInt()=codes.BUTTON_UP_PRESSED Then
Shift(screen, view_sprite, compositor, 0,-15) 'up 0,-15
Else If msg.GetInt()=codes.BUTTON_DOWN_PRESSED Then
Shift(screen, view_sprite, compositor, 0,+15) ' down 0,+15
Else If msg.GetInt() = codes.BUTTON_BACK_PRESSED ' back button
Exit While
End If
End If
End While
End Function
'''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''' Shift Function To shift the bitmap region
''''''''''by the given numbers
''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''''''
Function Shift(screen, view_sprite, compositor, xd, yd)
view_sprite.OffsetRegion(xd,yd,0,0)
compositor.drawAll()
screen.finish()
End Function